From 6440c8a201191c9eae32d6f61c14e5b4e4d10cbd Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Sat, 15 Aug 2020 12:55:02 +0200 Subject: [PATCH] Allow teachers to open lesson periods in the future if they are on the same day --- aleksis/apps/alsijil/preferences.py | 13 +++++++++++++ aleksis/apps/alsijil/views.py | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/aleksis/apps/alsijil/preferences.py b/aleksis/apps/alsijil/preferences.py index e9d3d2d2c..bcefc075e 100644 --- a/aleksis/apps/alsijil/preferences.py +++ b/aleksis/apps/alsijil/preferences.py @@ -27,3 +27,16 @@ class CarryOverDataToNextPeriods(BooleanPreference): help_text = _( "This will carry over data only if the data in the following periods are empty." ) + + +@site_preferences_registry.register +class AllowOpenPeriodsOnSameDay(BooleanPreference): + section = alsijil + name = "open_periods_same_day" + default = False + verbose_name = _( + "Allow teachers to open lesson periods on the same day and not just at the beginning of the period" + ) + help_text = _( + "Lessons in the past are not affected by this setting, you can open them whenever you want." + ) diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index 9c90ede28..0ed283e22 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -83,6 +83,10 @@ def lesson( wanted_week[lesson_period.period.weekday], lesson_period.period.time_start, ) > datetime.now() + and not ( + get_site_preferences()["alsijil__open_periods_same_day"] + and wanted_week[lesson_period.period.weekday] <= datetime.now().date() + ) and not request.user.is_superuser ): raise PermissionDenied( -- GitLab