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

Add link to register object in all columns of RegisterObjectTable

parent 7936ea14
No related branches found
No related tags found
1 merge request!152Overview of all register objects
...@@ -82,6 +82,10 @@ class GroupRoleTable(tables.Table): ...@@ -82,6 +82,10 @@ class GroupRoleTable(tables.Table):
self.columns.hide("delete") self.columns.hide("delete")
def get_link(value, record):
return record["register_object"].get_alsijil_url(record.get("week"))
class RegisterObjectTable(tables.Table): class RegisterObjectTable(tables.Table):
"""Table to show all register objects in an overview. """Table to show all register objects in an overview.
...@@ -93,13 +97,14 @@ class RegisterObjectTable(tables.Table): ...@@ -93,13 +97,14 @@ class RegisterObjectTable(tables.Table):
attrs = {"class": "highlight responsive-table"} attrs = {"class": "highlight responsive-table"}
status = tables.Column(accessor="register_object") status = tables.Column(accessor="register_object")
date = tables.Column(order_by="date_sort") date = tables.Column(order_by="date_sort", linkify=get_link)
period = tables.Column(order_by="period_sort") period = tables.Column(order_by="period_sort", linkify=get_link)
groups = tables.Column() groups = tables.Column(linkify=get_link)
subject = tables.Column() teachers = tables.Column(linkify=get_link)
topic = tables.Column() subject = tables.Column(linkify=get_link)
homework = tables.Column() topic = tables.Column(linkify=get_link)
group_note = tables.Column() homework = tables.Column(linkify=get_link)
group_note = tables.Column(linkify=get_link)
def render_status(self, value, record): def render_status(self, value, record):
return render_to_string( return render_to_string(
......
...@@ -232,7 +232,11 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d ...@@ -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 sub = filtered_substitutions[0] if filtered_substitutions else None
subject = sub.subject if sub and sub.subject else lesson_period.lesson.subject 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: if filter_subject and filter_subject != subject:
continue continue
...@@ -265,6 +269,7 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d ...@@ -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": f"{lesson_period.period.period}.",
"period_sort": lesson_period.period.period, "period_sort": lesson_period.period.period,
"groups": lesson_period.lesson.group_names, "groups": lesson_period.lesson.group_names,
"teachers": teachers,
"subject": subject.name, "subject": subject.name,
} }
if has_documentation: if has_documentation:
...@@ -315,6 +320,7 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d ...@@ -315,6 +320,7 @@ def generate_list_of_all_register_objects(filter_dict: Dict[str, Any]) -> List[d
"period": period, "period": period,
"period_sort": period_sort, "period_sort": period_sort,
"groups": register_object.group_names, "groups": register_object.group_names,
"teachers": register_object.teacher_names,
"subject": register_object.subject.name "subject": register_object.subject.name
if isinstance(register_object, ExtraLesson) if isinstance(register_object, ExtraLesson)
else _("Event"), else _("Event"),
......
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