diff --git a/aleksis/core/frontend/components/calendar/personal_event/PersonalEventDialog.vue b/aleksis/core/frontend/components/calendar/personal_event/PersonalEventDialog.vue index 33bd0b1286c331e9f9a39fd102ae7b2485b62c3e..3c94e2d38e9d7a7f5d689e98a568e4a0d7261691 100644 --- a/aleksis/core/frontend/components/calendar/personal_event/PersonalEventDialog.vue +++ b/aleksis/core/frontend/components/calendar/personal_event/PersonalEventDialog.vue @@ -255,8 +255,13 @@ export default { datetimeEnd: item.fullDay ? undefined : item.datetimeEnd, dateStart: item.fullDay ? item.dateStart : undefined, dateEnd: item.fullDay ? item.dateEnd : undefined, - recurrences: item.recurring === false ? "" : item.recurrences, - timezone: DateTime.local().zoneName, + ...(item.recurring + ? { + // Add clients timezone only if item is recurring + timezone: DateTime.local().zoneName, + recurrences: item.recurrences, + } + : {}), persons: this.checkPermission( "core.create_personal_event_with_invitations_rule", ) diff --git a/aleksis/core/frontend/components/calendar/personal_event/personalEvent.graphql b/aleksis/core/frontend/components/calendar/personal_event/personalEvent.graphql index 695c0719079a86ad3c428f526490a1d2c1b6ca76..a22bc0a465f0b2a64610a17a6f5693c6d509ab89 100644 --- a/aleksis/core/frontend/components/calendar/personal_event/personalEvent.graphql +++ b/aleksis/core/frontend/components/calendar/personal_event/personalEvent.graphql @@ -1,25 +1,30 @@ +fragment personalEventFields on PersonalEventType { + id + title + description + location + + datetimeStart + datetimeEnd + dateStart + dateEnd + timezone + recurrences + + persons { + id + fullName + } + groups { + id + shortName + } +} + mutation createPersonalEvents($input: [BatchCreatePersonalEventInput]!) { createPersonalEvents(input: $input) { items: personalEvents { - id - title - description - location - - datetimeStart - datetimeEnd - dateStart - dateEnd - recurrences - - persons { - id - fullName - } - groups { - id - shortName - } + ...personalEventFields } } } @@ -33,25 +38,7 @@ mutation deletePersonalEvents($ids: [ID]!) { mutation updatePersonalEvents($input: [BatchPatchPersonalEventInput]!) { updatePersonalEvents(input: $input) { items: personalEvents { - id - title - description - location - - datetimeStart - datetimeEnd - dateStart - dateEnd - recurrences - - persons { - id - fullName - } - groups { - id - shortName - } + ...personalEventFields } } } diff --git a/aleksis/core/schema/personal_event.py b/aleksis/core/schema/personal_event.py index 3bf36b2e4c352cee626529002897cfc6095b6e3e..e8655d160c0841332cc0edb20764f9a53d22bae3 100644 --- a/aleksis/core/schema/personal_event.py +++ b/aleksis/core/schema/personal_event.py @@ -24,15 +24,14 @@ class PersonalEventType(DjangoObjectType): "location", "datetime_start", "datetime_end", - "timezone", "date_start", "date_end", "owner", "persons", "groups", ) - convert_choices_to_enum = False + timezone = graphene.String() recurrences = graphene.String() @@ -53,7 +52,12 @@ class PersonalEventBatchCreateMutation(PermissionBatchPatchMixin, BaseBatchCreat "persons", "groups", ) - field_types = {"recurrences": graphene.String(), "location": graphene.String()} + field_types = { + "timezone": graphene.String(), + "recurrences": graphene.String(), + "location": graphene.String(), + } + optional_fields = ("timezone", "recurrences") @classmethod def get_permissions(cls, root, info, input) -> Iterable[str]: # noqa @@ -102,10 +106,24 @@ class PersonalEventBatchPatchMutation(BaseBatchPatchMutation): "persons", "groups", ) - field_types = {"recurrences": graphene.String(), "location": graphene.String()} + field_types = { + "timezone": graphene.String(), + "recurrences": graphene.String(), + "location": graphene.String(), + } + optional_fields = ("timezone", "recurrences") @classmethod def get_permissions(cls, root, info, input, id, obj) -> Iterable[str]: # noqa if info.context.user.has_perm("core.edit_personal_event_rule", obj): return [] return cls._meta.permissions + + @classmethod + def before_mutate(cls, root, info, input): # noqa + for event in input: + # Remove recurrences if none were received. + if "recurrences" not in event: + event["recurrences"] = "" + + return input