Skip to content

Commit

Permalink
Merge pull request #86 from QActf/BCK-44/del_role_in_resp_reg_user
Browse files Browse the repository at this point in the history
Bck 44/del role in resp reg user
  • Loading branch information
kokhlo authored Jul 15, 2024
2 parents a74fa26 + c6147fb commit ba1a7c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/api/endpoints/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from app.core.db import get_async_session
from app.core.user import auth_backend, fastapi_users
from app.crud.user import user_crud
from app.schemas.user import UserCreate, UserRead, UserUpdate
from app.schemas.user import UserCreate, UserRead, UserReadRegister, UserUpdate
from app.services.token_generator.tokens import token_generator

router = APIRouter()
Expand All @@ -24,7 +24,7 @@

router.include_router(
register.get_register_router(
UserRead,
UserReadRegister,
Annotated[UserCreate, Body(example=USER_VALUE)]
),
prefix='/auth',
Expand Down
1 change: 0 additions & 1 deletion app/api_docs_responses/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'is_active': True,
'is_superuser': True,
'is_verified': False,
'role': 'user',
'username': 'Имя',
'tariff_id': 0
}
Expand Down
13 changes: 8 additions & 5 deletions app/schemas/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
from app.core.constants import Role


class UserRead(schemas.BaseUser[int]):
role: Annotated[
Choice,
WithJsonSchema({'type': 'str'})
]
class UserReadRegister(schemas.BaseUser[int]):
username: str
tariff_id: Optional[int]

class Config:
from_attributes = True
arbitrary_types_allowed = True


class UserRead(UserReadRegister):
role: Annotated[
Choice,
WithJsonSchema({'type': 'str'})
]

@field_serializer('role')
def serialize_role(self, role: Choice, _info):
return role.code
Expand Down

0 comments on commit ba1a7c0

Please sign in to comment.