Skip to content
Snippets Groups Projects
Verified Commit 602e3f0b authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add docstrings

parent 0cc8f22f
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,7 @@ def lesson_periods_as_teacher(self): ...@@ -88,6 +88,7 @@ def lesson_periods_as_teacher(self):
def for_timetables(cls): def for_timetables(cls):
"""Return all announcements that should be shown in timetable views."""
return cls.objects.filter(show_in_timetables=True) return cls.objects.filter(show_in_timetables=True)
......
...@@ -13,6 +13,7 @@ from .models import LessonPeriod ...@@ -13,6 +13,7 @@ from .models import LessonPeriod
def _css_class_from_lesson_state( def _css_class_from_lesson_state(
record: Optional[LessonPeriod] = None, table: Optional[LessonsTable] = None record: Optional[LessonPeriod] = None, table: Optional[LessonsTable] = None
) -> str: ) -> str:
"""Return CSS class depending on lesson state."""
if record.get_substitution(record._week): if record.get_substitution(record._week):
if record.get_substitution(record._week).cancelled: if record.get_substitution(record._week).cancelled:
return "success" return "success"
...@@ -23,6 +24,7 @@ def _css_class_from_lesson_state( ...@@ -23,6 +24,7 @@ def _css_class_from_lesson_state(
class LessonsTable(tables.Table): class LessonsTable(tables.Table):
"""Table for daily lessons and management of substitutions."""
class Meta: class Meta:
attrs = {"class": "highlight"} attrs = {"class": "highlight"}
row_attrs = {"class": _css_class_from_lesson_state} row_attrs = {"class": _css_class_from_lesson_state}
......
from datetime import date
from aleksis.apps.chronos.models import TimePeriod
from django.utils.formats import date_format from django.utils.formats import date_format
def format_m2m(f, attr: str = "short_name"): def format_m2m(f, attr: str = "short_name") -> str:
"""Join a attribute of all elements of a ManyToManyField."""
return ", ".join([getattr(x, attr) for x in f.all()]) return ", ".join([getattr(x, attr) for x in f.all()])
def format_date_period(date, period): def format_date_period(day: date, period: TimePeriod) -> str:
return "{}, {}.".format(date_format(date), period.period) """Format date and time period."""
return "{}, {}.".format(date_format(day), period.period)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment