Skip to content

Commit

Permalink
feat(server): add lesson type in lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
smart7even committed Nov 12, 2023
1 parent 3748bd0 commit cb7978d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/types/lesson.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re
from dataclasses import dataclass
from datetime import datetime
from typing import Optional


@dataclass(frozen=True)
Expand Down Expand Up @@ -37,3 +39,8 @@ def get_day_start_date(self) -> datetime:
day_pattern = '%d.%m.%Y'
day = datetime.strptime(self.day, day_pattern)
return day

def get_lesson_type(self) -> Optional[str]:
match = re.search(r'\((.*?)\)$', self.name)

return match.group(1) if match else None
2 changes: 2 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Optional
from datetime import datetime

Expand Down Expand Up @@ -162,6 +163,7 @@ def lessons_to_dict(lessons: list[Lesson]) -> list[dict]:
'end': end_time,
'professor': lesson.professor,
'location': lesson.location,
'lesson_type': lesson.get_lesson_type()
}

dict_lessons.append(dict_lesson)
Expand Down

0 comments on commit cb7978d

Please sign in to comment.