diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000000000000000000000000000000000..ccc75937408fdbeb5e724bb618e223bb390182a4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +<!-- AlekSIS is developed on EduGit. GitHub only serves as + backup mirror and to help people find the project. If + possible, please submit your merge request on EduGit! + + EduGit accepts logins with GitHub accounts. +--> + +[ ] I have read the above and have no way to contribute on EduGit +[ ] I understand that GitHub's terms of service exclude young and + learning contributors, but still cannot contribute on EduGit + instead. diff --git a/aleksis/apps/chronos/model_extensions.py b/aleksis/apps/chronos/model_extensions.py index 269ce3fc292aeb4ff587982d1272f38d678f1743..fefea7d4a3db279d9a3b46c951d973a6c7b76e4b 100644 --- a/aleksis/apps/chronos/model_extensions.py +++ b/aleksis/apps/chronos/model_extensions.py @@ -83,7 +83,7 @@ def lesson_periods_as_teacher(self): @Person.method def lessons_on_day(self, day: date): """Get all lessons of this person (either as participant or teacher) on the given day.""" - return LessonPeriod.objects.on_day(day).filter_from_person(self).order_by("period__period") + return LessonPeriod.objects.order_by("period__period").on_day(day).filter_from_person(self) @Person.method @@ -92,6 +92,10 @@ def _adjacent_lesson( ) -> Union["LessonPeriod", None]: """Get next/previous lesson of the person (either as participant or teacher) on the same day.""" daily_lessons = self.lessons_on_day(day) + + if not daily_lessons: + return None + ids = list(daily_lessons.values_list("id", flat=True)) index = ids.index(lesson_period.pk) diff --git a/aleksis/apps/chronos/models.py b/aleksis/apps/chronos/models.py index 9b27fa0ef465e09411778d2f08a223d2698dafa4..03788999f74feb384cb1780f09ebb32a92040d39 100644 --- a/aleksis/apps/chronos/models.py +++ b/aleksis/apps/chronos/models.py @@ -19,7 +19,6 @@ from django.utils.translation import gettext_lazy as _ from cache_memoize import cache_memoize from calendarweek.django import CalendarWeek, i18n_day_abbr_choices_lazy, i18n_day_name_choices_lazy from colorfield.fields import ColorField -from django_global_request.middleware import get_request from aleksis.apps.chronos.managers import ( AbsenceQuerySet, @@ -515,10 +514,9 @@ class LessonPeriod(ExtensibleModel, WeekAnnotationMixin): class TimetableWidget(DashboardWidget): template = "chronos/widget.html" - def get_context(self): + def get_context(self, request): from aleksis.apps.chronos.util.build import build_timetable # noqa - request = get_request() context = {"has_plan": True} wanted_day = TimePeriod.get_next_relevant_day(timezone.now().date(), datetime.now().time()) diff --git a/aleksis/apps/chronos/templates/chronos/partials/elements.html b/aleksis/apps/chronos/templates/chronos/partials/elements.html index 825a3291b9d904f277223f5ededa05a301d1e86f..a7df614d20a2bc7fb2c203d90b0473756294da0a 100644 --- a/aleksis/apps/chronos/templates/chronos/partials/elements.html +++ b/aleksis/apps/chronos/templates/chronos/partials/elements.html @@ -1,11 +1,11 @@ -<div class="card lesson-card {% if week_day == active_day %} z-depth-5 active {% endif %}"> +<div class="card lesson-card {% if active_day and week_day == active_day %} z-depth-5 active {% endif %}"> <div class="card-content"> {% for element in elements %} {% if element.label_ == "lesson_period" %} {% include "chronos/partials/lesson.html" with lesson_period=element %} - {% elif element.label_ == "extra_lesson" %} + {% elif element.label_ == "extra_lesson" and smart %} {% include "chronos/partials/extra_lesson.html" with extra_lesson=element %} - {% elif element.label_ == "event" %} + {% elif element.label_ == "event" and smart %} {% include "chronos/partials/event.html" with event=element %} {% endif %} {% endfor %} diff --git a/aleksis/apps/chronos/templates/chronos/partials/lesson.html b/aleksis/apps/chronos/templates/chronos/partials/lesson.html index 70ef9e72558e55b4c14757dbb0048ba243a76fd3..5b7ceb6c511f43087f2f76af5429967131682d92 100644 --- a/aleksis/apps/chronos/templates/chronos/partials/lesson.html +++ b/aleksis/apps/chronos/templates/chronos/partials/lesson.html @@ -12,9 +12,7 @@ class="{% if lesson_period.get_substitution and smart %}lesson-with-sub{% endif %}" > <p> - {% if lesson_period.is_hol and smart %} - {# Do nothing #} - {% elif lesson_period.get_substitution and smart %} + {% if lesson_period.get_substitution and smart %} {% with sub=lesson_period.get_substitution %} {# SUBSTITUTION #} {% if type.value == "room" and lesson_period.room != lesson_period.get_room and lesson_period.get_room != el %} diff --git a/aleksis/apps/chronos/templates/chronos/partials/supervision.html b/aleksis/apps/chronos/templates/chronos/partials/supervision.html index 10ff51888939929b2bb3183c254b5a7838b91a12..c0364cfdb7130073436fde78587652b5dd760a78 100644 --- a/aleksis/apps/chronos/templates/chronos/partials/supervision.html +++ b/aleksis/apps/chronos/templates/chronos/partials/supervision.html @@ -1,6 +1,6 @@ {% load i18n %} -<div class="card lesson-card supervision-card"> +<div class="card lesson-card supervision-card {% if active_day and week_day == active_day %} z-depth-5 active {% endif %}"> <div class="card-content"> {% if supervision %} <div style=" diff --git a/aleksis/apps/chronos/templates/chronos/partials/week_timetable.html b/aleksis/apps/chronos/templates/chronos/partials/week_timetable.html index 95ff53c309ac4e3676f2f51a3f062bc628f858d2..22030da954fd3f96ccf324e4ef7b50ab76862835 100644 --- a/aleksis/apps/chronos/templates/chronos/partials/week_timetable.html +++ b/aleksis/apps/chronos/templates/chronos/partials/week_timetable.html @@ -1,12 +1,12 @@ {# Week days #} <div class="row"> - <div class="col s1"> + <div class="col {% if active_day %}s1{% else %}s2{% endif %}"> </div> {# Show short weekdays on tablets #} {% for weekday in weekdays_short %} <div class="col s2 hide-on-large-only"> - <div class="card timetable-title-card"> + <div class="card timetable-title-card {% if active_day and weekday.date == active_day %} z-depth-5 {% endif %}"> <div class="card-content"> <span class="card-title"> {{ weekday.name }} @@ -28,7 +28,7 @@ {# Show long weekdays elsewere #} {% for weekday in weekdays %} <div class="col {% if weekday.date == active_day %} s3 {% else %} s2 {% endif %} hide-on-med-only"> - <div class="card timetable-title-card {% if weekday.date == active_day %} z-depth-5 {% endif %}"> + <div class="card timetable-title-card {% if active_day and weekday.date == active_day %} z-depth-5 {% endif %}"> <div class="card-content"> <span class="card-title"> {{ weekday.name }} @@ -51,7 +51,7 @@ {# Lessons #} {% for row in timetable %} <div class="row"> - <div class="col s1"> + <div class="col {% if active_day %}s1{% else %}s2{% endif %}"> {% if row.type == "period" %} {% include "chronos/partials/period_time.html" with period=row.period periods=periods %} {% endif %}