Refactor Lesson model to simplify structure and remove unused fields
This commit is contained in:
parent
5e57097926
commit
f0d9cfa7be
1 changed files with 31 additions and 89 deletions
|
@ -1,102 +1,44 @@
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
class LessonDate(BaseModel):
|
#class Change(BaseModel):
|
||||||
Timestamp: int
|
# Id: int
|
||||||
Date: date
|
# Type: int
|
||||||
DateDisplay: str
|
# IsMerge: bool
|
||||||
Time: str
|
# Separation: bool
|
||||||
|
|
||||||
class Change(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Type: int
|
|
||||||
IsMerge: bool
|
|
||||||
Separation: bool
|
|
||||||
|
|
||||||
|
|
||||||
class Substitution(BaseModel):
|
#class Substitution(BaseModel):
|
||||||
Id: int
|
# Id: int
|
||||||
UnitId: int
|
# UnitId: int
|
||||||
ScheduleId: int
|
# ScheduleId: int
|
||||||
LessonDate: LessonDate
|
# LessonDate: LessonDate
|
||||||
|
|
||||||
class Distribution(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Key: str
|
|
||||||
Shortcut: str
|
|
||||||
Name: str
|
|
||||||
PartType: str
|
|
||||||
|
|
||||||
|
|
||||||
class Room(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Code: str
|
|
||||||
|
|
||||||
|
|
||||||
class TimeSlot(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Start: str
|
|
||||||
End: str
|
|
||||||
Display: str
|
|
||||||
Position: int
|
|
||||||
|
|
||||||
|
|
||||||
class Subject(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Key: str
|
|
||||||
Name: str
|
|
||||||
Kod: str
|
|
||||||
Position: int
|
|
||||||
|
|
||||||
|
|
||||||
class Teacher(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Surname: str
|
|
||||||
Name: str
|
|
||||||
DisplayName: str
|
|
||||||
|
|
||||||
|
|
||||||
class Clazz(BaseModel):
|
|
||||||
Id: int
|
|
||||||
Key: str
|
|
||||||
DisplayName: str
|
|
||||||
Symbol: str
|
|
||||||
|
|
||||||
|
# TODO: Add a model for the substitutions
|
||||||
|
|
||||||
class Lesson(BaseModel):
|
class Lesson(BaseModel):
|
||||||
Id: int
|
id: int
|
||||||
MergeChangeId: int | None
|
position : int
|
||||||
Event: str | None
|
date: date
|
||||||
Date: date
|
room: str | None
|
||||||
Room: Room
|
start: str
|
||||||
TimeSlot: TimeSlot
|
end: str
|
||||||
Subject: Subject
|
subject: str | None
|
||||||
TeacherPrimary: Teacher
|
teacher: str | None
|
||||||
TeacherSecondary: Teacher | None
|
group: str | None
|
||||||
Change: Change | None
|
visible: bool
|
||||||
Clazz: Clazz
|
|
||||||
Distribution: Distribution | None
|
|
||||||
PupilAlias: str | None
|
|
||||||
Visible: bool
|
|
||||||
Substitution: Substitution | None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_hebe_dict(data: dict):
|
def from_hebe_dict(data: dict):
|
||||||
return Lesson(
|
return Lesson(
|
||||||
Id=data["Id"],
|
id=data["Id"],
|
||||||
MergeChangeId=data["MergeChangeId"],
|
position = data["TimeSlot"]["Position"],
|
||||||
Event=data["Event"],
|
date=datetime.fromtimestamp(data["Date"]["Timestamp"] / 1000),
|
||||||
Date=date.fromtimestamp(data["Date"]["Timestamp"] / 1000),
|
room=data["Room"]["Code"],
|
||||||
Room=Room(**data["Room"]),
|
start=data["TimeSlot"]["Start"],
|
||||||
TimeSlot=TimeSlot(**data["TimeSlot"]),
|
end=data["TimeSlot"]["End"],
|
||||||
Subject=Subject(**data["Subject"]),
|
subject=data["Subject"]["Name"],
|
||||||
TeacherPrimary=Teacher(**data["TeacherPrimary"]),
|
teacher=data["TeacherPrimary"]["DisplayName"],
|
||||||
TeacherSecondary=Teacher(**data["TeacherSecondary"]) if data["TeacherSecondary"] else None,
|
group=data["Distribution"]["Shortcut"] if data["Distribution"] else None,
|
||||||
TeacherSecondary2=Teacher(**data["TeacherSecondary2"]) if data["TeacherSecondary2"] else None,
|
visible=data["Visible"],
|
||||||
Change=Change(**data["Change"]) if data["Change"] else None,
|
|
||||||
Clazz=Clazz(**data["Clazz"]),
|
|
||||||
Distribution=Distribution(**data["Distribution"]) if data["Distribution"] else None,
|
|
||||||
PupilAlias=data["PupilAlias"],
|
|
||||||
Visible=data["Visible"],
|
|
||||||
Substitution=Substitution(**data["Substitution"]) if data["Substitution"] else None,
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue