Skip to content
Snippets Groups Projects
Commit 546bcab7 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Fix timezone handling

parent 623bca5e
No related branches found
No related tags found
2 merge requests!352Draft: Resolve "Add dialog with each lesson's students",!350Resolve "Add simple course book list"
Pipeline #178515 failed
......@@ -574,8 +574,8 @@ class Documentation(CalendarEvent):
existing_documentations := (
event_reference_obj := event["REFERENCE_OBJECT"]
).documentation.filter(
datetime_start=event["DTSTART"].dt.replace(tzinfo=timezone.utc),
datetime_end=event["DTEND"].dt.replace(tzinfo=timezone.utc),
datetime_start=event["DTSTART"].dt,
datetime_end=event["DTEND"].dt,
)
).exists()
else cls(
......
......@@ -171,9 +171,8 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
# Timezone removal is necessary due to ISO style offsets are no valid timezones.
# Instead, we take the timezone from the lesson_event and save it in a dedicated field.
obj = Documentation.objects.create(
datetime_start=datetime.fromisoformat(datetime_start).replace(tzinfo=timezone.utc),
datetime_end=datetime.fromisoformat(datetime_end).replace(tzinfo=timezone.utc),
timezone=lesson_event.timezone,
datetime_start=datetime.fromisoformat(datetime_start).astimezone(lesson_event.timezone),
datetime_end=datetime.fromisoformat(datetime_end).astimezone(lesson_event.timezone),
lesson_event=lesson_event,
course=lesson_event.course,
subject=lesson_event.subject,
......
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