Skip to content

Commit

Permalink
feat(server): add elective property in lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
smart7even committed Dec 16, 2023
1 parent 22877b7 commit d87f467
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
config.yaml
__pycache__
venv
.idea
dbdata
.idea
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

5 changes: 4 additions & 1 deletion core/types/lesson.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def get_day_start_date(self) -> datetime:
return day

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

return match.group(1) if match else None

def get_is_elective(self) -> Optional[bool]:
return self.name.startswith("Выбор ")
7 changes: 1 addition & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ services:
- SCHEDULE_BOT_TOKEN=${SCHEDULE_BOT_TOKEN}
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
db:
image: postgres:15.4
image: postgres:latest
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- dbdata:/var/lib/postgresql/data

volumes:
dbdata:
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def lessons_to_dict(lessons: list[Lesson]) -> list[dict]:
'end': end_time,
'professor': lesson.professor,
'location': lesson.location,
'lesson_type': lesson.get_lesson_type()
'lesson_type': lesson.get_lesson_type(),
'is_elective': lesson.get_is_elective()
}

dict_lessons.append(dict_lesson)
Expand Down

0 comments on commit d87f467

Please sign in to comment.