From 54f6c46e9f00d8a39d9f1f03ecbc6a166c4eb11c Mon Sep 17 00:00:00 2001 From: Julian Leucker <leuckerj@gmail.com> Date: Tue, 14 May 2024 11:23:33 +0200 Subject: [PATCH] Create participations when creating documentations --- aleksis/apps/alsijil/models.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index c4487066c..2bf3b78c3 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -678,6 +678,24 @@ class Documentation(CalendarEvent): ) obj.teachers.set(teachers.all()) obj.save() + + # Create Participation Statuses + # Cannot use djangos bulk_create method, as then the save method of the + # superclass wouldn't be called + + for member in lesson_event.all_members: + # TODO: Check for preexisting absences in kolego + # TODO: maybe only create if the lesson start is in the past + status = ParticipationStatus.objects.create( + person=member, + related_documentation=obj, + datetime_start=datetime_start, + datetime_end=datetime_end, + timezone=lesson_event.timezone, + ) + status.groups_of_person.set(member.member_of.all()) + status.save() + return obj @classmethod -- GitLab