From dd0e3b8c34e4f688da27e1be99ba0a53ed96a3ad Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Wed, 10 Mar 2021 11:38:45 +0100 Subject: [PATCH] Add link to register object in all columns of RegisterObjectTable --- aleksis/apps/alsijil/tables.py | 19 ++++++++++++------- aleksis/apps/alsijil/util/alsijil_helpers.py | 8 +++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/aleksis/apps/alsijil/tables.py b/aleksis/apps/alsijil/tables.py index c7d995c43..8bd77545c 100644 --- a/aleksis/apps/alsijil/tables.py +++ b/aleksis/apps/alsijil/tables.py @@ -82,6 +82,10 @@ class GroupRoleTable(tables.Table): self.columns.hide("delete") +def get_link(value, record): + return record["register_object"].get_alsijil_url(record.get("week")) + + class RegisterObjectTable(tables.Table): """Table to show all register objects in an overview. @@ -93,13 +97,14 @@ class RegisterObjectTable(tables.Table): attrs = {"class": "highlight responsive-table"} status = tables.Column(accessor="register_object") - date = tables.Column(order_by="date_sort") - period = tables.Column(order_by="period_sort") - groups = tables.Column() - subject = tables.Column() - topic = tables.Column() - homework = tables.Column() - group_note = tables.Column() + date = tables.Column(order_by="date_sort", linkify=get_link) + period = tables.Column(order_by="period_sort", linkify=get_link) + groups = tables.Column(linkify=get_link) + teachers = tables.Column(linkify=get_link) + subject = tables.Column(linkify=get_link) + topic = tables.Column(linkify=get_link) + homework = tables.Column(linkify=get_link) + group_note = tables.Column(linkify=get_link) def render_status(self, value, record): return render_to_string( diff --git a/aleksis/apps/alsijil/util/alsijil_helpers.py b/aleksis/apps/alsijil/util/alsijil_helpers.py index 8da8711e1..a78788833 100644 --- a/aleksis/apps/alsijil/util/alsijil_helpers.py +++ b/aleksis/apps/alsijil/util/alsijil_helpers.py @@ -232,7 +232,11 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d sub = filtered_substitutions[0] if filtered_substitutions else None subject = sub.subject if sub and sub.subject else lesson_period.lesson.subject - + teachers = ( + sub.teacher_names + if sub and sub.teachers.all() + else lesson_period.lesson.teacher_names + ) if filter_subject and filter_subject != subject: continue @@ -265,6 +269,7 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d "period": f"{lesson_period.period.period}.", "period_sort": lesson_period.period.period, "groups": lesson_period.lesson.group_names, + "teachers": teachers, "subject": subject.name, } if has_documentation: @@ -315,6 +320,7 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d "period": period, "period_sort": period_sort, "groups": register_object.group_names, + "teachers": register_object.teacher_names, "subject": register_object.subject.name if isinstance(register_object, ExtraLesson) else _("Event"), -- GitLab