57 lines
1.1 KiB
Python
57 lines
1.1 KiB
Python
import uuid
|
|
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from barker.schemas import to_camel
|
|
from barker.schemas.role import RoleItem
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class UserIn(BaseModel):
|
|
name: str
|
|
password: str
|
|
locked_out: bool
|
|
roles: List[RoleItem]
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class User(UserIn):
|
|
id_: uuid.UUID
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class UserMe(UserIn):
|
|
id_: str
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class UserLink(BaseModel):
|
|
id_: Optional[uuid.UUID]
|
|
name: Optional[str]
|
|
|
|
class Config:
|
|
fields = {"id_": "id"}
|
|
|
|
|
|
class UserList(BaseModel):
|
|
id_: uuid.UUID
|
|
name: str
|
|
roles: List[str]
|
|
last_device: str
|
|
last_date: Optional[datetime]
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
|