Skip to content
Snippets Groups Projects
Verified Commit ea2cc407 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Move settings check for carry_data_over to save method

Makes it possible to use the function in other contexts
parent 5914e36b
Branches
Tags
1 merge request!79Resolve "Carry over the data of the first lesson for double (or triple, ...) lessons"
......@@ -111,9 +111,6 @@ class LessonDocumentation(ExtensibleModel):
Can be deactivated using site preference ``alsijil__carry_over``.
"""
if get_site_preferences()["alsijil__carry_over"] and (
self.topic or self.homework or self.group_note
):
try:
second_period = LessonPeriod.objects.get(
lesson=self.lesson_period.lesson,
......@@ -122,8 +119,7 @@ class LessonDocumentation(ExtensibleModel):
)
lesson_documentation = second_period.get_or_create_lesson_documentation(
CalendarWeek(
week=self.week,
year=self.lesson_period.lesson.get_year(self.week),
week=self.week, year=self.lesson_period.lesson.get_year(self.week),
)
)
......@@ -148,6 +144,9 @@ class LessonDocumentation(ExtensibleModel):
pass
def save(self, *args, **kwargs):
if get_site_preferences()["alsijil__carry_over"] and (
self.topic or self.homework or self.group_note
):
self._carry_over_data()
super().save(*args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment