Skip to content

Commit

Permalink
Api serializers (#4)
Browse files Browse the repository at this point in the history
* Start api models for contribution agreement (#82)

* api models for contribution

* change import sorting and format

* fixture data for testing

* change model fields

* test string parsing

* Migrate models

* fixture data for testing

* api models and tests files

* fix import statements

* fix code format

* Fix static types

* fix linting test file format

* import fix

* Check static code

* import sort

* update DateTime Field

* Tests for models

* Repository testing

* fix class name

* tests for models

* correct formatting and comments

* Change meta classes

* Fix code format and imports

* Delete all fruit files

* Delete last fruit migration

* Fix migration issue

* change data fields

* Apply changes after review

* apply initial migrations

* Fix contributor type error

* Add verbose names

* Fix import error

* Create api serializers

* Test the serializer's functionality

* Check static code

* Add module doc strings

* Contributor tests

* Apply changes from second review

* Migrate models

* Fix doc strings

* apply review changes
  • Loading branch information
SalmanAsh authored Jul 16, 2024
1 parent 507407d commit 7b59088
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
© Ocado Group
Created on 02/07/2024 at 12:00:12(+01:00).
"""

from .agreement_signature import AgreementSignatureSerializer
from .contributor import ContributorSerializer
17 changes: 17 additions & 0 deletions api/serializers/agreement_signature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
© Ocado Group
Created on 12/07/2024 at 14:07:45(+01:00).
"""

from codeforlife.serializers import ModelSerializer
from codeforlife.user.models import User

from ..models import AgreementSignature


class AgreementSignatureSerializer(ModelSerializer[User, AgreementSignature]):
"""Agreement serializer class"""

class Meta:
model = AgreementSignature
fields = ["id", "contributor", "agreement_id", "signed_at"]
18 changes: 18 additions & 0 deletions api/serializers/agreement_signature_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
© Ocado Group
Created on 12/07/2024 at 17:16:58(+01:00).
"""

from codeforlife.tests import ModelSerializerTestCase
from codeforlife.user.models import User

from ..models import AgreementSignature
from .agreement_signature import AgreementSignatureSerializer


class TestAgreementSignatureSerializer(
ModelSerializerTestCase[User, AgreementSignature]
):
"""Test the Agreement Signature serializers"""

model_serializer_class = AgreementSignatureSerializer
16 changes: 16 additions & 0 deletions api/serializers/contributor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
© Ocado Group
Created on 12/07/2024 at 14:07:59(+01:00).
"""
from codeforlife.serializers import ModelSerializer
from codeforlife.user.models import User

from ..models import Contributor


class ContributorSerializer(ModelSerializer[User, Contributor]):
"""Contributor serializer class"""

class Meta:
model = Contributor
fields = ["id", "email", "name", "location", "html_url", "avatar_url"]
16 changes: 16 additions & 0 deletions api/serializers/contributor_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
© Ocado Group
Created on 12/07/2024 at 11:36:23(+01:00).
"""

from codeforlife.tests import ModelSerializerTestCase
from codeforlife.user.models import User

from ..models import Contributor
from .contributor import ContributorSerializer


class TestContributorSerializer(ModelSerializerTestCase[User, Contributor]):
"""Test the Contributor serializers"""

model_serializer_class = ContributorSerializer

0 comments on commit 7b59088

Please sign in to comment.