Skip to content
Snippets Groups Projects
Commit 2f79cae3 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '131-make-carry-over-of-absences-configurable' into 'master'

Resolve "Make carry over of absences configurable"

Closes #131

See merge request !137
parents 616d414e ffe66828
No related branches found
No related tags found
1 merge request!137Resolve "Make carry over of absences configurable"
Pipeline #5626 passed
......@@ -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
......
......@@ -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."))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment