From d77a165f21ab5fffb92edb61a84f30d78a8364d9 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Sun, 11 Aug 2024 17:20:10 +0200 Subject: [PATCH] Set correct base mutations for amend mutations --- aleksis/apps/chronos/schema/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/aleksis/apps/chronos/schema/__init__.py b/aleksis/apps/chronos/schema/__init__.py index 253f56f1..27900348 100644 --- a/aleksis/apps/chronos/schema/__init__.py +++ b/aleksis/apps/chronos/schema/__init__.py @@ -2,13 +2,13 @@ from datetime import timezone import graphene from graphene_django import DjangoObjectType -from graphene_django_cud.mutations import ( - DjangoBatchCreateMutation, - DjangoBatchDeleteMutation, - DjangoBatchPatchMutation, -) from aleksis.core.models import Group, Person, Room +from aleksis.core.schema.base import ( + BaseBatchCreateMutation, + BaseBatchDeleteMutation, + BaseBatchPatchMutation, +) from ..models import LessonEvent from ..util.chronos_helpers import get_groups, get_rooms, get_teachers @@ -80,7 +80,7 @@ class DatetimeTimezoneMixin: return value -class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, DjangoBatchCreateMutation): +class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, BaseBatchCreateMutation): class Meta: model = LessonEvent permissions = ("chronos.edit_substitution_rule",) @@ -98,12 +98,13 @@ class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, DjangoBatchCreateMut @classmethod def before_save(cls, root, info, input, created_objects): # noqa: A002 + super().before_save(root, info, input, created_objects) for obj in created_objects: obj.timezone = obj.amends.timezone return created_objects -class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, DjangoBatchPatchMutation): +class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, BaseBatchPatchMutation): class Meta: model = LessonEvent permissions = ("chronos.edit_substitution_rule",) @@ -111,12 +112,13 @@ class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, DjangoBatchPatchMutat @classmethod def before_save(cls, root, info, input, updated_objects): # noqa: A002 + super().before_save(root, info, input, updated_objects) for obj in updated_objects: obj.timezone = obj.amends.timezone return updated_objects -class AmendLessonBatchDeleteMutation(DjangoBatchDeleteMutation): +class AmendLessonBatchDeleteMutation(BaseBatchDeleteMutation): class Meta: model = LessonEvent permissions = ("chronos.delete_substitution_rule",) -- GitLab