Skip to content

Commit

Permalink
set locale from family creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTraveylan committed Aug 9, 2024
1 parent 0fffd86 commit 0206c47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions auth_api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class RegisterCreateSchema(BaseModel):
family_name: str
username: str
password: str
locale: str

@field_validator("family_name")
def family_name_length(cls, value: str) -> str:
Expand Down
3 changes: 2 additions & 1 deletion auth_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def register_create_family(request: HttpRequest):
"family_name": data.get("family_name"),
"username": data.get("username"),
"password": data.get("password"),
"locale": data.get("locale"),
}

parsed_data: RegisterCreateSchema | None = None
Expand All @@ -67,7 +68,7 @@ def register_create_family(request: HttpRequest):
return JsonResponse({"message": "Username already exists"}, status=400)

family = Family.objects.create(family_name=parsed_data.family_name)
FamilySettings.objects.create(family=family)
FamilySettings.objects.create(family=family, locale=parsed_data.locale)
user = User.objects.create_user(
username=parsed_data.username, password=parsed_data.password
)
Expand Down

0 comments on commit 0206c47

Please sign in to comment.