Skip to content
Snippets Groups Projects
Verified Commit 39a85c05 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Correctly set timezones with amended lesson events

parent ba21458f
No related branches found
No related tags found
1 merge request!310Resolve "Implement Vue substitution frontend"
Pipeline #144783 failed
from datetime import timezone
import graphene
from graphene_django import DjangoObjectType
from graphene_django_cud.mutations import DjangoCreateMutation, DjangoPatchMutation
......@@ -71,6 +73,21 @@ class AmendLessonCreateMutation(DjangoCreateMutation):
"comment",
)
@classmethod
def handle_datetime_start(cls, value, name, info) -> int:
value = value.replace(tzinfo=timezone.utc)
return value
@classmethod
def handle_datetime_end(cls, value, name, info) -> int:
value = value.replace(tzinfo=timezone.utc)
return value
@classmethod
def before_save(cls, root, info, input, obj):
obj.timezone = obj.amends.timezone
return obj
class AmendLessonPatchMutation(DjangoPatchMutation):
class Meta:
......@@ -78,6 +95,21 @@ class AmendLessonPatchMutation(DjangoPatchMutation):
permissions = ("chronos.edit_substitution_rule",)
only_fields = ("subject", "teachers", "groups", "rooms", "cancelled", "comment")
@classmethod
def handle_datetime_start(cls, value, name, info) -> int:
value = value.replace(tzinfo=timezone.utc)
return value
@classmethod
def handle_datetime_end(cls, value, name, info) -> int:
value = value.replace(tzinfo=timezone.utc)
return value
@classmethod
def before_save(cls, root, info, input, id, obj):
obj.timezone = obj.amends.timezone
return obj
class TimetableType(graphene.Enum):
TEACHER = "teacher"
......
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