From 3d00d7eecbc76e4b3a5309e43fb7c05c20a7a5d1 Mon Sep 17 00:00:00 2001
From: Julian Leucker <leuckerj@gmail.com>
Date: Mon, 12 Aug 2024 19:34:45 +0200
Subject: [PATCH] Remove special time handling

---
 aleksis/apps/chronos/schema/__init__.py | 36 ++++++-------------------
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/aleksis/apps/chronos/schema/__init__.py b/aleksis/apps/chronos/schema/__init__.py
index 253f56f1..eff984d6 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
@@ -60,27 +60,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, DjangoBatchCreateMutation):
+class AmendLessonBatchCreateMutation(BaseBatchCreateMutation):
     class Meta:
         model = LessonEvent
         permissions = ("chronos.edit_substitution_rule",)
@@ -103,7 +83,7 @@ class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, DjangoBatchCreateMut
         return created_objects
 
 
-class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, DjangoBatchPatchMutation):
+class AmendLessonBatchPatchMutation(BaseBatchPatchMutation):
     class Meta:
         model = LessonEvent
         permissions = ("chronos.edit_substitution_rule",)
@@ -116,7 +96,7 @@ class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, DjangoBatchPatchMutat
         return updated_objects
 
 
-class AmendLessonBatchDeleteMutation(DjangoBatchDeleteMutation):
+class AmendLessonBatchDeleteMutation(BaseBatchDeleteMutation):
     class Meta:
         model = LessonEvent
         permissions = ("chronos.delete_substitution_rule",)
-- 
GitLab