Sith/counter/schemas.py

29 lines
865 B
Python
Raw Normal View History

2024-10-12 15:30:19 +00:00
from datetime import datetime
2024-07-18 18:23:30 +00:00
2024-10-12 15:30:19 +00:00
from ninja import FilterSchema, ModelSchema
from pydantic import Field
from core.models import User
2024-07-18 18:23:30 +00:00
from core.schemas import SimpleUserSchema
2024-10-12 15:30:19 +00:00
from counter.models import Counter, Permanency
2024-07-18 18:23:30 +00:00
class CounterSchema(ModelSchema):
barmen_list: list[SimpleUserSchema]
is_open: bool
class Meta:
model = Counter
fields = ["id", "name", "type", "club", "products"]
2024-10-12 15:30:19 +00:00
class PermanencySchema(ModelSchema):
class Meta:
model = Permanency
fields = ["user", "counter", "start", "end", "activity"]
class PermanencyFilterSchema(FilterSchema):
start_date: datetime | None = Field(None, q="start__gte")
end_date: datetime | None = Field(None, q="end__lte")
barmen: set[int] | None = Field(None, q="user_id__in")
counter: set[int] | None = Field(None, q="counter_id__in")