2024-10-19 22:18:53 +00:00
|
|
|
from typing import Annotated
|
|
|
|
|
|
|
|
from annotated_types import MinLen
|
|
|
|
from ninja import Field, FilterSchema, ModelSchema
|
2024-07-18 18:23:30 +00:00
|
|
|
|
|
|
|
from core.schemas import SimpleUserSchema
|
2024-11-15 01:23:27 +00:00
|
|
|
from counter.models import Counter, Customer, Product
|
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-19 22:18:53 +00:00
|
|
|
|
|
|
|
|
2024-11-15 01:23:27 +00:00
|
|
|
class CustomerBalance(ModelSchema):
|
|
|
|
class Meta:
|
|
|
|
model = Customer
|
|
|
|
fields = ["amount"]
|
|
|
|
|
|
|
|
|
2024-10-19 22:18:53 +00:00
|
|
|
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"]
|