feat: nested department sections, attaching department sections in the user editor
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
from typing import Optional
|
||||
|
||||
from schemas.base import BaseSchema, OkMessageSchema
|
||||
from schemas.user import UserSchema
|
||||
|
||||
|
||||
# region Entities
|
||||
|
||||
class UserDepartmentSectionSchema(BaseSchema):
|
||||
user: UserSchema
|
||||
is_chief: bool
|
||||
|
||||
|
||||
class DepartmentSectionBaseSchema(BaseSchema):
|
||||
name: str
|
||||
department_id: int
|
||||
department_id: Optional[int]
|
||||
parent_department_section_id: Optional[int]
|
||||
|
||||
|
||||
class DepartmentSectionSchema(DepartmentSectionBaseSchema):
|
||||
class DepartmentSectionBriefSchema(DepartmentSectionBaseSchema):
|
||||
id: int
|
||||
users: list[UserSchema] = []
|
||||
|
||||
|
||||
class DepartmentSectionSchema(DepartmentSectionBriefSchema):
|
||||
users: list[UserDepartmentSectionSchema] = []
|
||||
sections: list["DepartmentSectionSchema"] = []
|
||||
|
||||
|
||||
class DepartmentBaseSchema(BaseSchema):
|
||||
@@ -46,6 +58,7 @@ class UpdateDepartmentSectionRequest(BaseSchema):
|
||||
class AddUserRequest(BaseSchema):
|
||||
user_id: int
|
||||
section_id: int
|
||||
is_chief: bool
|
||||
|
||||
|
||||
class DeleteUserRequest(BaseSchema):
|
||||
@@ -73,6 +86,10 @@ class DeleteDepartmentResponse(OkMessageSchema):
|
||||
pass
|
||||
|
||||
|
||||
class GetDepartmentSectionsResponse(BaseSchema):
|
||||
department_sections: list[DepartmentSectionBriefSchema]
|
||||
|
||||
|
||||
class CreateDepartmentSectionResponse(OkMessageSchema):
|
||||
pass
|
||||
|
||||
|
||||
@@ -16,12 +16,17 @@ class PassportImageSchema(BaseSchema):
|
||||
image_url: str
|
||||
|
||||
|
||||
class UserDepartmentSectionsSchema(BaseSchema):
|
||||
section_id: int
|
||||
is_chief: bool
|
||||
|
||||
|
||||
class BasicUser(BaseSchema):
|
||||
telegram_id: int
|
||||
phone_number: str | None = None
|
||||
first_name: str
|
||||
second_name: str
|
||||
patronymic: str
|
||||
patronymic: str = ""
|
||||
comment: str
|
||||
passport_data: str | None = None
|
||||
|
||||
@@ -51,6 +56,7 @@ class BaseUser(BasicUser):
|
||||
class UserSchema(BaseUser):
|
||||
role: RoleSchema
|
||||
position: Optional[PositionSchema] = None
|
||||
department_sections: list[UserDepartmentSectionsSchema] | None = []
|
||||
|
||||
|
||||
class UserUpdate(BaseUser):
|
||||
@@ -68,6 +74,10 @@ class UpdateUserRequest(BaseSchema):
|
||||
data: UserUpdate
|
||||
|
||||
|
||||
class UpdateUserDepartmentSectionsRequest(BaseSchema):
|
||||
department_sections: list[UserDepartmentSectionsSchema]
|
||||
|
||||
|
||||
class CreateUserRequest(BaseSchema):
|
||||
data: UserCreate
|
||||
|
||||
@@ -83,6 +93,10 @@ class UpdateUserResponse(OkMessageSchema):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateUserDepartmentSectionsResponse(OkMessageSchema):
|
||||
pass
|
||||
|
||||
|
||||
class CreateUserResponse(OkMessageSchema):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user