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

Remove real_amends as its longer necessary (amends is fixed!)

parent dcc6a604
No related branches found
No related tags found
1 merge request!301New data model based on calendar events
Pipeline #173047 failed
......@@ -1375,7 +1375,7 @@ class LessonEvent(CalendarEvent):
@property
def actual_groups(self: LessonEvent):
return self.groups.all() if self.amends else self.real_amends.groups.all()
return self.amends.groups.all() if self.amends else self.groups.all()
@property
def all_members(self: LessonEvent) -> list[Person]:
......@@ -1385,7 +1385,7 @@ class LessonEvent(CalendarEvent):
def all_teachers(self: LessonEvent) -> list[Person]:
all_teachers = list(self.teachers.all())
if self.amends:
all_teachers += list(self.real_amends.teachers.all())
all_teachers += list(self.amends.teachers.all())
return all_teachers
@property
......@@ -1403,7 +1403,7 @@ class LessonEvent(CalendarEvent):
@property
def room_names_with_amends(self: LessonEvent) -> str:
my_room_names = self.room_names
amended_room_names = self.real_amends.room_names if self.amends else ""
amended_room_names = self.amends.room_names if self.amends else ""
if my_room_names and amended_room_names:
return _("{} (instead of {})").format(my_room_names, amended_room_names)
......@@ -1414,7 +1414,7 @@ class LessonEvent(CalendarEvent):
@property
def teacher_names_with_amends(self: LessonEvent) -> str:
my_teacher_names = self.teacher_names
amended_teacher_names = self.real_amends.teacher_names if self.amends else ""
amended_teacher_names = self.amends.teacher_names if self.amends else ""
if my_teacher_names and amended_teacher_names:
return _("{} (instead of {})").format(my_teacher_names, amended_teacher_names)
......@@ -1425,7 +1425,7 @@ class LessonEvent(CalendarEvent):
@property
def subject_name_with_amends(self: LessonEvent) -> str:
my_subject = self.subject.name
amended_subject = self.real_amends.subject.name if self.amends else ""
amended_subject = self.amends.subject.name if self.amends else ""
if my_subject and amended_subject:
return _("{} (instead of {})").format(my_subject, amended_subject)
......@@ -1433,13 +1433,6 @@ class LessonEvent(CalendarEvent):
return amended_subject
return my_subject
@property
def real_amends(self: LessonEvent) -> LessonEvent:
# FIXME THIS IS AWFUL SLOW
if self.amends:
return LessonEvent.objects.get(pk=self.amends.pk)
return self
@classmethod
def value_title(cls, reference_object: LessonEvent, request) -> str:
"""Get the title of the event."""
......@@ -1468,8 +1461,8 @@ class LessonEvent(CalendarEvent):
return "#eeeeee"
if reference_object.subject:
return reference_object.subject.colour_bg
if reference_object.amends and reference_object.real_amends.subject:
return reference_object.real_amends.subject.colour_bg
if reference_object.amends and reference_object.amends.subject:
return reference_object.amends.subject.colour_bg
return super().value_color(reference_object, request)
@classmethod
......@@ -1493,11 +1486,12 @@ class LessonEvent(CalendarEvent):
@classmethod
def value_meta(cls, reference_object: LessonEvent, request) -> str:
"""Get the meta of the event."""
real_amends = reference_object.real_amends
return {
"amended": bool(reference_object.amends),
"amends": cls.value_meta(real_amends, request) if reference_object.amends else None,
"amends": cls.value_meta(reference_object.amends, request)
if reference_object.amends
else None,
"teachers": [
{
"id": t.pk,
......
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