Skip to content
Snippets Groups Projects
Commit a7e98030 authored by permcu's avatar permcu
Browse files

Fix AbsencesForPersonsCreateMutation

id -> pk
datetime.now needs timezone
get_or_create instead of just create -> could be called several times
ParticipationStatus is a CalendarEvent -> more args
parent d7ed2a56
No related branches found
No related tags found
1 merge request!356Add dialog for creation of long-term absences
......@@ -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,
......
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