-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from ArtrenH/main
2023-10-15
- Loading branch information
Showing
27 changed files
with
1,053 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,4 +166,5 @@ backend/schools/private_data | |
creds.json | ||
proxies.json | ||
|
||
/test_scripts | ||
/test_scripts | ||
/downloaded_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from __future__ import annotations | ||
|
||
import copy | ||
import dataclasses | ||
import typing | ||
|
||
from . import models | ||
|
||
|
||
@dataclasses.dataclass | ||
class DefaultPlanInfo: | ||
unchanged_lessons: list[models.Lesson] = dataclasses.field(default_factory=list) | ||
week: int | None = None | ||
|
||
@classmethod | ||
def from_lessons(cls, lessons: typing.Iterable[models.Lesson]) -> DefaultPlanInfo: | ||
out = cls() | ||
|
||
for lesson in lessons: | ||
if len(lesson.parsed_info.paragraphs) != 0: | ||
continue | ||
|
||
if not lesson._is_scheduled or lesson.is_internal or lesson.subject_changed: | ||
continue | ||
|
||
lesson = copy.deepcopy(lesson) | ||
|
||
if lesson.teacher_changed: | ||
lesson.teachers = None | ||
|
||
if lesson.room_changed: | ||
lesson.rooms = None | ||
|
||
if lesson.forms_changed: | ||
lesson.forms = None | ||
assert False, f"{cls.__name__}.from_lessons() only supports lessons from form plans." | ||
|
||
out.unchanged_lessons.append(lesson) | ||
|
||
return out | ||
|
||
def serialize(self): | ||
return { | ||
"unchanged_lessons": [lesson.serialize() for lesson in self.unchanged_lessons], | ||
"week": self.week | ||
} | ||
|
||
@classmethod | ||
def deserialize(cls, data): | ||
return cls( | ||
unchanged_lessons=[models.Lesson.deserialize(lesson) for lesson in data["unchanged_lessons"]], | ||
week=data["week"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.