Skip to content
Snippets Groups Projects
Commit 5d4676ce authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '250-fix-timezone-handling-with-substitutions-amend-dialog' into 'master'

Resolve "Fix timezone handling with substitutions/amend dialog"

Closes #250

See merge request !361
parents 3211fca8 a2115e41
No related branches found
No related tags found
1 merge request!361Resolve "Fix timezone handling with substitutions/amend dialog"
Pipeline #192282 failed
......@@ -157,8 +157,8 @@ export default {
return {
...item,
amends: this.selectedEvent.meta.id,
datetimeStart: this.selectedEvent.startDateTime.toUTC().toISO(),
datetimeEnd: this.selectedEvent.endDateTime.toUTC().toISO(),
datetimeStart: this.$toUTCISO(this.selectedEvent.startDateTime),
datetimeEnd: this.$toUTCISO(this.selectedEvent.endDateTime),
// Normalize cancelled, v-checkbox returns null & does not
// honor false-value.
cancelled: item.cancelled ? true : false,
......
from datetime import timezone
import graphene
from graphene_django import DjangoObjectType
......@@ -60,27 +58,7 @@ class LessonEventType(DjangoObjectType):
amends = graphene.Field(lambda: LessonEventType, required=False)
class DatetimeTimezoneMixin:
"""Handle datetimes for mutations with CalendarEvent objects.
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
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
class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, BaseBatchCreateMutation):
class AmendLessonBatchCreateMutation(BaseBatchCreateMutation):
class Meta:
model = LessonEvent
permissions = ("chronos.edit_substitution_rule",)
......@@ -104,7 +82,7 @@ class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, BaseBatchCreateMutat
return created_objects
class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, BaseBatchPatchMutation):
class AmendLessonBatchPatchMutation(BaseBatchPatchMutation):
class Meta:
model = LessonEvent
permissions = ("chronos.edit_substitution_rule",)
......
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