mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
27 lines
639 B
Python
27 lines
639 B
Python
from datetime import datetime
|
|
|
|
from ninja import FilterSchema, ModelSchema
|
|
from pydantic import Field
|
|
|
|
from counter.models import Counter, Permanency
|
|
|
|
|
|
class CounterSchema(ModelSchema):
|
|
class Meta:
|
|
model = Counter
|
|
fields = ["id", "name", "type"]
|
|
|
|
|
|
class PermanencySchema(ModelSchema):
|
|
counter: CounterSchema
|
|
|
|
class Meta:
|
|
model = Permanency
|
|
fields = ["start", "end"]
|
|
|
|
|
|
class PermanencyFilterSchema(FilterSchema):
|
|
start_date: datetime | None = Field(None, q="start__gte")
|
|
end_date: datetime | None = Field(None, q="end__lte")
|
|
counter: set[int] | None = Field(None, q="counter_id__in")
|