diff --git a/biscuit/apps/chronos/tables.py b/biscuit/apps/chronos/tables.py index 7b5968b8a860a840481b4a7fccd24f68af9c9556..e48e9c4fcc81334b28fa5ea6a94372b60358d075 100644 --- a/biscuit/apps/chronos/tables.py +++ b/biscuit/apps/chronos/tables.py @@ -2,6 +2,14 @@ from django.utils.translation import ugettext_lazy as _ import django_tables2 as tables from django_tables2.utils import A + +def _css_class_from_lesson_state(record: Optional[LessonPeriod] = None, table: Optional[LessonTable] = None) -> str: + if record.get_substitution(table._week): + return 'table-warning' + else: + return '' + + class LessonsTable(tables.Table): class Meta: attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'} @@ -15,3 +23,6 @@ class LessonsTable(tables.Table): def __init__(self, week, *args, **kwargs): self._week = week super().__init__(*args, **kwargs) + + class Meta: + row_attrs = {'class': _css_class_from_lesson_state}