diff --git a/aleksis/apps/chronos/settings.py b/aleksis/apps/chronos/settings.py index 2c861857f006770095861fdfdd249195a3477c16..559cdca9e7ac2ce981a3730d9073d85973fbd9c7 100644 --- a/aleksis/apps/chronos/settings.py +++ b/aleksis/apps/chronos/settings.py @@ -1,6 +1,26 @@ 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_SHORTEN_GROUPS": ( + False, + _( + "If there are more groups than the limit set in CHRONOS_SHORTEN_GROUPS_LIMIT, add text collapsible." + ), + ), + "CHRONOS_SHORTEN_GROUPS_LIMIT": ( + 4, + _( + "If there are more groups than this limit and CHRONOS_SHORTEN_GROUPS is enabled, add text collapsible." + ), + ), "CHRONOS_SUBSTITUTIONS_PRINT_DAY_NUMBER": ( 2, _("Number of days shown on substitutions print view"), @@ -12,6 +32,9 @@ CONSTANCE_CONFIG = { } CONSTANCE_CONFIG_FIELDSETS = { "Chronos settings": ( + "CHRONOS_USE_PARENT_GROUPS", + "CHRONOS_SHORTEN_GROUPS", + "CHRONOS_SHORTEN_GROUPS_LIMIT", "CHRONOS_SUBSTITUTIONS_PRINT_DAY_NUMBER", "CHRONOS_SUBSTITUTIONS_SHOW_HEADER_BOX", ), diff --git a/aleksis/apps/chronos/static/css/chronos/timetable.css b/aleksis/apps/chronos/static/css/chronos/timetable.css index 16846c6059e92d49a8ba89258a7b259793c427b0..c25d6750eeed8f9965c06b3f6da267916ee4c616 100644 --- a/aleksis/apps/chronos/static/css/chronos/timetable.css +++ b/aleksis/apps/chronos/static/css/chronos/timetable.css @@ -35,7 +35,7 @@ li.active > a > .sidenav-badge { flex-direction: column; } -.lesson-card .card-content div { +.lesson-card .card-content > div { padding: 3px; flex: auto; width: 100%; diff --git a/aleksis/apps/chronos/templates/chronos/partials/group.html b/aleksis/apps/chronos/templates/chronos/partials/group.html new file mode 100644 index 0000000000000000000000000000000000000000..d2e345d53df2bec9020b9de38139726744d1effe --- /dev/null +++ b/aleksis/apps/chronos/templates/chronos/partials/group.html @@ -0,0 +1,3 @@ +<a href="{% url "timetable" "group" item.pk %}"> + {{ item.short_name }}{% if not forloop.last %},{% endif %} +</a> 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..fea197c9bca0fcd87e1e4b36b065a70e1076917b --- /dev/null +++ b/aleksis/apps/chronos/templates/chronos/partials/groups_part.html @@ -0,0 +1,7 @@ +{% if groups.count > config.CHRONOS_SHORTEN_GROUPS_LIMIT and config.CHRONOS_SHORTEN_GROUPS %} + {% include "components/text_collapsible.html" with template="chronos/partials/group.html" qs=groups %} +{% else %} + {% for group in groups %} + {% include "chronos/partials/group.html" with item=group %} + {% endfor %} +{% endif %}