From 526c53fbf85f3d86749aff19755c002ad59b131a Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Wed, 1 Apr 2020 16:49:40 +0200 Subject: [PATCH] Add support for showing parent groups instead of original groups if there is only one group and this group has parent groups Advance #71 --- aleksis/apps/chronos/settings.py | 9 +++++++++ .../chronos/templates/chronos/partials/groups.html | 10 +++++----- .../templates/chronos/partials/groups_part.html | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 aleksis/apps/chronos/templates/chronos/partials/groups_part.html diff --git a/aleksis/apps/chronos/settings.py b/aleksis/apps/chronos/settings.py index 2c861857..9c0df07f 100644 --- a/aleksis/apps/chronos/settings.py +++ b/aleksis/apps/chronos/settings.py @@ -1,6 +1,14 @@ from django.utils.translation import gettext_lazy as _ CONSTANCE_CONFIG = { + "CHRONOS_USE_PARENT_GROUPS": ( + False, + _( + "If an lesson or substitution has only one group" + " and this group has parent groups," + " show the parent groups instead of the original group." + ), + ), "CHRONOS_SUBSTITUTIONS_PRINT_DAY_NUMBER": ( 2, _("Number of days shown on substitutions print view"), @@ -12,6 +20,7 @@ CONSTANCE_CONFIG = { } CONSTANCE_CONFIG_FIELDSETS = { "Chronos settings": ( + "CHRONOS_USE_PARENT_GROUPS", "CHRONOS_SUBSTITUTIONS_PRINT_DAY_NUMBER", "CHRONOS_SUBSTITUTIONS_SHOW_HEADER_BOX", ), diff --git a/aleksis/apps/chronos/templates/chronos/partials/groups.html b/aleksis/apps/chronos/templates/chronos/partials/groups.html index 3ccfc00c..26c620bb 100644 --- a/aleksis/apps/chronos/templates/chronos/partials/groups.html +++ b/aleksis/apps/chronos/templates/chronos/partials/groups.html @@ -1,5 +1,5 @@ -{% for group in groups %} - <a href="{% url "timetable" "group" group.pk %}"> - {{ group.short_name }}{% if not forloop.last %},{% endif %} - </a> -{% endfor %} +{% if groups.count == 1 and groups.0.parent_groups.all and config.CHRONOS_USE_PARENT_GROUPS %} + {% include "chronos/partials/groups_part.html" with groups=groups.0.parent_groups.all %} +{% else %} + {% include "chronos/partials/groups_part.html" with groups=groups %} +{% endif %} diff --git a/aleksis/apps/chronos/templates/chronos/partials/groups_part.html b/aleksis/apps/chronos/templates/chronos/partials/groups_part.html new file mode 100644 index 00000000..3ccfc00c --- /dev/null +++ b/aleksis/apps/chronos/templates/chronos/partials/groups_part.html @@ -0,0 +1,5 @@ +{% for group in groups %} + <a href="{% url "timetable" "group" group.pk %}"> + {{ group.short_name }}{% if not forloop.last %},{% endif %} + </a> +{% endfor %} -- GitLab