diff --git a/aleksis/apps/alsijil/preferences.py b/aleksis/apps/alsijil/preferences.py index 4ced04f41ba56db628b4dc4438242a81bc36f5eb..bd51c03e87ed612fb6ae4d865f5b911448241bb8 100644 --- a/aleksis/apps/alsijil/preferences.py +++ b/aleksis/apps/alsijil/preferences.py @@ -46,6 +46,14 @@ 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 CarryOverPersonalNotesToNextPeriods(BooleanPreference): + section = alsijil + name = "carry_over_personal_notes" + default = True + verbose_name = _("Carry over personal notes to all following lesson periods on the same day.") + + @site_preferences_registry.register class AllowOpenPeriodsOnSameDay(BooleanPreference): section = alsijil diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index 2b49259d926ae956a7ee48d53529f8632d99edca..397019f31564c68a4b24a912d7487ba03d51ad96 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -153,17 +153,19 @@ def lesson( reversion.set_user(request.user) instances = personal_note_formset.save() - # Iterate over personal notes and carry changed absences to following lessons - with reversion.create_revision(): - reversion.set_user(request.user) - for instance in instances: - instance.person.mark_absent( - wanted_week[lesson_period.period.weekday], - lesson_period.period.period + 1, - instance.absent, - instance.excused, - instance.excuse_type, - ) + if get_site_preferences()["alsijil__carry_over_personal_notes"]: + # Iterate over personal notes + # and carry changed absences to following lessons + with reversion.create_revision(): + reversion.set_user(request.user) + for instance in instances: + instance.person.mark_absent( + wanted_week[lesson_period.period.weekday], + lesson_period.period.period + 1, + instance.absent, + instance.excused, + instance.excuse_type, + ) messages.success(request, _("The personal notes have been saved."))