diff --git a/aleksis/apps/chronos/settings.py b/aleksis/apps/chronos/settings.py index 2c861857f006770095861fdfdd249195a3477c16..9c0df07f0ca65d6b5f06e16443bff602d06a1cf5 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 3ccfc00c4f6789fe4878880179e837408601c6ba..26c620bb3f174540cbf4154c283ced6978358ba0 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 0000000000000000000000000000000000000000..3ccfc00c4f6789fe4878880179e837408601c6ba --- /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 %}