diff --git a/aleksis/apps/alsijil/tables.py b/aleksis/apps/alsijil/tables.py index e7fb6df6da3e9a80e0ae3e51e8c8674200e94176..22a6b21cad3abf5519678082c5ebf36d9d0c4579 100644 --- a/aleksis/apps/alsijil/tables.py +++ b/aleksis/apps/alsijil/tables.py @@ -94,13 +94,17 @@ class PersonalNoteTable(tables.Table): period = tables.Column( verbose_name=_("Period"), accessor=A("period_formatted"), order_by=A("order_period") ) - groups = tables.Column(verbose_name=_("Groups"), accessor=A("register_object__group_names")) - teachers = tables.Column( - verbose_name=_("Teachers"), accessor=A("register_object__teacher_names") + groups = tables.Column( + verbose_name=_("Groups"), + accessor=A("register_object__group_names"), + order_by=A("order_groups"), ) - subject = tables.Column( - verbose_name=_("Subject"), accessor=A("register_object__get_subject__name") + teachers = tables.Column( + verbose_name=_("Teachers"), + accessor=A("register_object__teacher_names"), + order_by=A("order_teachers"), ) + subject = tables.Column(verbose_name=_("Subject"), accessor=A("subject")) absent = tables.Column() late = tables.Column() excused = tables.Column(verbose_name=_("Excuse")) diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index 8e6e41b47cc6524a5e49d1dade07ed7e43780acc..6fd7ec6c01a29c6cdaed7da1c497f4d847104e0d 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -822,6 +822,16 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp When(extra_lesson__isnull=False, then="extra_lesson__period__period"), When(lesson_period__isnull=False, then="lesson_period__period__period"), ), + order_groups=Case( + When(event__isnull=False, then="event__groups"), + When(extra_lesson__isnull=False, then="extra_lesson__groups"), + When(lesson_period__isnull=False, then="lesson_period__lesson__groups"), + ), + order_teachers=Case( + When(event__isnull=False, then="event__teachers"), + When(extra_lesson__isnull=False, then="extra_lesson__teachers"), + When(lesson_period__isnull=False, then="lesson_period__lesson__teachers"), + ), ) .order_by( "-school_term_start", "-order_year", "-order_week", "-order_weekday", "order_period",