diff --git a/aleksis/apps/alsijil/preferences.py b/aleksis/apps/alsijil/preferences.py index e9d3d2d2c0eaca9c2d7838ab79594f860f4dc1c0..bcefc075e2ac5025ebaf2b361abe3f2325b16563 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 a84415b41559af43ee747d60b4e4a43a95afeb5f..f0c2ad33df596f616501166bdc6c2101572f7b24 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(