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

Fix timezone handling when creating documentations

parent d9b61a53
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 #170431 failed
from datetime import datetime from datetime import datetime, timezone
import graphene import graphene
from graphene_django.types import DjangoObjectType from graphene_django.types import DjangoObjectType
from graphene_django_cud.mutations import ( from graphene_django_cud.mutations import (
...@@ -149,16 +149,18 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation): ...@@ -149,16 +149,18 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
): ):
raise PermissionDenied() raise PermissionDenied()
# 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.
return Documentation.objects.create( return Documentation.objects.create(
datetime_start=datetime.fromisoformat(datetime_start), datetime_start=datetime.fromisoformat(datetime_start).replace(tzinfo=timezone.utc),
datetime_end=datetime.fromisoformat(datetime_end), datetime_end=datetime.fromisoformat(datetime_end).replace(tzinfo=timezone.utc),
timezone=lesson_event.timezone,
lesson_event=lesson_event, lesson_event=lesson_event,
course=lesson_event.course, course=lesson_event.course,
subject=lesson_event.subject, subject=lesson_event.subject,
topic=doc.topic or "", topic=doc.topic or "",
homework=doc.homework or "", homework=doc.homework or "",
group_note=doc.group_note or "", group_note=doc.group_note or "",
) # TODO: Add course & subject )
else: else:
obj = Documentation.objects.get(id=id) obj = Documentation.objects.get(id=id)
......
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