Skip to content
Snippets Groups Projects
Commit d804aa9b authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add row_attr helper to highlight lessons with subsitutions. Advances #19, #12.

parent cb454a99
1 merge request!9WIP: Add way to edit substitution
...@@ -2,6 +2,14 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -2,6 +2,14 @@ from django.utils.translation import ugettext_lazy as _
import django_tables2 as tables import django_tables2 as tables
from django_tables2.utils import A 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 LessonsTable(tables.Table):
class Meta: class Meta:
attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'} attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'}
...@@ -15,3 +23,6 @@ class LessonsTable(tables.Table): ...@@ -15,3 +23,6 @@ class LessonsTable(tables.Table):
def __init__(self, week, *args, **kwargs): def __init__(self, week, *args, **kwargs):
self._week = week self._week = week
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
class Meta:
row_attrs = {'class': _css_class_from_lesson_state}
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