Skip to content

Commit

Permalink
feat!: reporter API's birth_year renamed to birthyear
Browse files Browse the repository at this point in the history
KK-1024.

The birth_year of the reporter API was renamed to birthyear
to make the code and field names more consistent.
  • Loading branch information
nikomakela committed Jan 22, 2024
1 parent e1b6fc2 commit b712e73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions children/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ def validate_child_data(child_data):
except ValidationError as e:
raise DataValidationError(e.message)
if "birthyear" in child_data:
birth_year = child_data["birthyear"]
birthyear = child_data["birthyear"]
if (
child_data["birthyear"] > localdate().year
or not Project.objects.filter(year=birth_year).exists()
or not Project.objects.filter(year=birthyear).exists()
):
raise DataValidationError("Illegal birthyear.")
return child_data
Expand Down
10 changes: 5 additions & 5 deletions reports/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def get_primary_contact_language(contact_languages: List[str]):
value=[
{
"registration_date": "2021-02-18",
"birth_year": 2021,
"birthyear": 2021,
"contact_language": "fin",
"languages_spoken_at_home": ["fin", "nor", "__OTHER__"],
},
{
"registration_date": "2021-03-18",
"birth_year": 2020,
"birthyear": 2020,
"contact_language": "eng",
"languages_spoken_at_home": [],
},
Expand All @@ -104,7 +104,7 @@ class ChildSerializer(serializers.ModelSerializer):
)
)
registration_date = serializers.SerializerMethodField()
birth_year = serializers.SerializerMethodField()
birthyear = serializers.SerializerMethodField()
contact_language = serializers.SerializerMethodField()
languages_spoken_at_home = serializers.SerializerMethodField(
help_text="Array of ISO 639-3 (language) or ISO 639-5 (language family) "
Expand All @@ -117,7 +117,7 @@ class Meta:
"child_birthyear_postal_code_guardian_emails_hash",
"child_name_birthyear_postal_code_guardian_emails_hash",
"registration_date",
"birth_year",
"birthyear",
"postal_code",
"contact_language",
"languages_spoken_at_home",
Expand All @@ -141,7 +141,7 @@ def get_child_name_birthyear_postal_code_guardian_emails_hash(
def get_registration_date(self, obj: Child) -> date:
return localdate(obj.created_at)

def get_birth_year(self, obj: Child) -> int:
def get_birthyear(self, obj: Child) -> int:
return obj.birthyear

@extend_schema_field(
Expand Down
10 changes: 5 additions & 5 deletions reports/tests/snapshots/snap_test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

snapshots["test_children_endpoint 1"] = [
{
"birth_year": 2020,
"birthyear": 2020,
"child_birthyear_postal_code_guardian_emails_hash": "3b78fc2b60381829414bd2bd9ea53e90123d9cd7faeb35f86f5038d669dd96e0",
"child_name_birthyear_postal_code_guardian_emails_hash": "bd94f9a87d842f6889f10aa72528a273c27fb864fe7b14b7b38b2b37a59b615a",
"contact_language": "eng",
Expand All @@ -17,7 +17,7 @@
"registration_date": "2021-04-05",
},
{
"birth_year": 2021,
"birthyear": 2021,
"child_birthyear_postal_code_guardian_emails_hash": "d9653e3210babd7c8d6094f069ddfbf790d6b16d368d0b14e0d4f9d1d2eed8aa",
"child_name_birthyear_postal_code_guardian_emails_hash": "cde8b66cfb17f9dd1e3a27b34ced099567555c09ac53ab8d96eb6f108b481a78",
"contact_language": "fin",
Expand All @@ -26,7 +26,7 @@
"registration_date": "2021-02-02",
},
{
"birth_year": 2021,
"birthyear": 2021,
"child_birthyear_postal_code_guardian_emails_hash": "73471fad7bbcffa243a695f211ffd2c0ddb89531d747548709c3677ecbe4a0cc",
"child_name_birthyear_postal_code_guardian_emails_hash": "c056d2e1b6ca2ab0189ce068567cb6d3951928283e8ebbb384ec20d3a85f632e",
"contact_language": "swe",
Expand All @@ -35,10 +35,10 @@
"registration_date": "2021-03-03",
},
{
"birth_year": 2020,
"birthyear": 2020,
"child_birthyear_postal_code_guardian_emails_hash": "f1694b9c7d7a45c8606d9506f171025079940fcc97d5e125e1cc73495461f378",
"child_name_birthyear_postal_code_guardian_emails_hash": "92d10305295a1210620ae3158c5aeecc24d9018be279042e8226d120cbfdb978",
"contact_language": "eng",
"contact_language": "swe",
"languages_spoken_at_home": [],
"postal_code": "44444",
"registration_date": "2021-04-06",
Expand Down

0 comments on commit b712e73

Please sign in to comment.