mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
33 lines
748 B
Python
33 lines
748 B
Python
from typing import Annotated
|
|
|
|
from annotated_types import MinLen
|
|
from ninja import Field, FilterSchema, ModelSchema
|
|
|
|
from core.schemas import SimpleUserSchema
|
|
from counter.models import Counter, Product
|
|
|
|
|
|
class CounterSchema(ModelSchema):
|
|
barmen_list: list[SimpleUserSchema]
|
|
is_open: bool
|
|
|
|
class Meta:
|
|
model = Counter
|
|
fields = ["id", "name", "type", "club", "products"]
|
|
|
|
|
|
class CounterFilterSchema(FilterSchema):
|
|
search: Annotated[str, MinLen(1)] = Field(None, q="name__icontains")
|
|
|
|
|
|
class SimplifiedCounterSchema(ModelSchema):
|
|
class Meta:
|
|
model = Counter
|
|
fields = ["id", "name"]
|
|
|
|
|
|
class ProductSchema(ModelSchema):
|
|
class Meta:
|
|
model = Product
|
|
fields = ["id", "name", "code"]
|