diff --git a/aleksis/apps/alsijil/schema/absences.py b/aleksis/apps/alsijil/schema/absences.py index 57a39bcff3b70abdac4602f69190098981c9f61d..5a4561a208a5ab4ccd1cddb73eab43797026fd77 100644 --- a/aleksis/apps/alsijil/schema/absences.py +++ b/aleksis/apps/alsijil/schema/absences.py @@ -39,9 +39,9 @@ class AbsencesForPersonsCreateMutation(graphene.Mutation): # Create doc for dummies that are already in the past future = False for dummy in dummies: - lesson_event, dummy_start, dummy_end = Documentation.parse_dummy(dummy.id) + lesson_event, dummy_start, dummy_end = Documentation.parse_dummy(dummy.pk) - if dummy_start < datetime.now(): + if dummy_start < datetime.now(dummy_start.tzinfo): # In the past -> Create a Documentation docs.append( Documentation.create_from_lesson_event( @@ -57,19 +57,22 @@ class AbsencesForPersonsCreateMutation(graphene.Mutation): # Create a ParticipationStatus for each documentation for doc in docs: # Set person & absence_reason directly from id - ParticipationStatus.objects.create( + ParticipationStatus.objects.get_or_create( person_id=person, related_documentation=doc, absence_reason_id=reason, + datetime_start=doc.datetime_start, + datetime_end=doc.datetime_end, + timezone=doc.timezone, ) # If there are still dummy documentations in the future # create a Kolego Absence if future: # TODO: Are date_start & date_end from CalendarEvent enough - # or more needed? + # or is time needed? # Set reason & person directly from id - Absence.objects.create( + Absence.objects.get_or_create( date_start=datetime.now().date(), date_end=end, reason_id=reason,