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

Fix DatetimeTimezoneMixin to work with create and patch mutations

parent fd036dc1
No related branches found
No related tags found
1 merge request!310Resolve "Implement Vue substitution frontend"
Pipeline #147055 failed
......@@ -60,9 +60,10 @@ class LessonEventType(DjangoObjectType):
class DatetimeTimezoneMixin:
"""Handle datetimes for mutations with CalendarEvent objects.
Since the client sends timezone information as ISO string
which only includes an offset (+00:00 UTC). Because an offset
is no valid timezone, we set UTC as timezone directly.
This is necessary because the client sends timezone information as
ISO string which only includes an offset (+00:00 UTC) and an
offset is not a valid timezone. Instead we set UTC as timezone
here directly.
"""
@classmethod
......@@ -76,7 +77,14 @@ class DatetimeTimezoneMixin:
return value
@classmethod
def before_save(cls, root, info, input, obj):
def before_save(cls, root, info, input, obj, patch_obj=False):
# before_save has different signatures for different mutations
# This handles create & patch
# https://graphene-django-cud.readthedocs.io/en/latest/guide/other-hooks.html?highlight=before_save#before-save
if patch_obj:
obj = patch_obj
obj.timezone = obj.amends.timezone
return obj
......
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