mirror of
https://github.com/ae-utbm/sith.git
synced 2026-10-05 18:34:15 +00:00
api to save timetable
This commit is contained in:
1 parent
7044a06546
commit
7a0df3d8a7
3 files changed
+65
-2
No files matched your search
@@ -0,0 +1,35 @@
|
||||
from typing import Annotated
|
||||
|
||||
from annotated_types import Ge, Le
|
||||
from ninja import ModelSchema, Schema
|
||||
from pydantic import Field
|
||||
|
||||
from timetable.models import Timetable, TimetableSlot
|
||||
|
||||
|
||||
class TimetableSlotSchema(Schema):
|
||||
weekday: TimetableSlot.WeekDay = Field(
|
||||
description=(
|
||||
f"{TimetableSlot.WeekDay.MONDAY} is monday, "
|
||||
f"{TimetableSlot.WeekDay.TUESDAY} is tuesday, etc."
|
||||
)
|
||||
)
|
||||
start_at: Annotated[int, Ge(0), Le(96)]
|
||||
end_at: Annotated[int, Ge(0), Le(96)]
|
||||
|
||||
class Meta:
|
||||
model = TimetableSlot
|
||||
fields = ["start_at", "end_at"]
|
||||
|
||||
|
||||
class CreateTimetableSchema(Schema):
|
||||
is_viewable: bool
|
||||
slots: list[TimetableSlotSchema]
|
||||
|
||||
|
||||
class TimetableSchema(ModelSchema):
|
||||
slots: list[TimetableSlotSchema]
|
||||
|
||||
class Meta:
|
||||
model = Timetable
|
||||
fields = ["id", "semester"]
|
||||
Reference in new issue
Block a user