Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bck 44/del role in resp reg user #86

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading