From 6f974c30e15ab73821955359b314557429264af6 Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Wed, 16 Oct 2024 02:32:07 +0200
Subject: [PATCH] Reformat

---
 .../frontend/components/LessonInformation.vue |  9 ++---
 .../substitutions/SubstitutionCard.vue        | 36 +++++++++----------
 .../substitutions/SubstitutionInformation.vue |  3 +-
 aleksis/apps/chronos/frontend/index.js        |  6 ++--
 aleksis/apps/chronos/models.py                | 22 +++++++-----
 aleksis/apps/chronos/rules.py                 |  8 ++---
 aleksis/apps/chronos/schema/__init__.py       | 21 ++++++-----
 aleksis/apps/chronos/util/predicates.py       |  2 +-
 8 files changed, 55 insertions(+), 52 deletions(-)

diff --git a/aleksis/apps/chronos/frontend/components/LessonInformation.vue b/aleksis/apps/chronos/frontend/components/LessonInformation.vue
index c73072d0..072745c4 100644
--- a/aleksis/apps/chronos/frontend/components/LessonInformation.vue
+++ b/aleksis/apps/chronos/frontend/components/LessonInformation.vue
@@ -43,11 +43,9 @@ export default {
     getSubject(lesson) {
       if (lesson.subject) {
         return lesson.subject;
-      }
-      else if (lesson.course?.subject) {
+      } else if (lesson.course?.subject) {
         return lesson.course.subject;
-      }
-      else if (lesson.amends?.subject) {
+      } else if (lesson.amends?.subject) {
         return lesson.amends.subject;
       }
       return undefined;
@@ -56,8 +54,7 @@ export default {
     getCourse(lesson) {
       if (lesson.course) {
         return lesson.course;
-      }
-      else if (lesson.amends?.course) {
+      } else if (lesson.amends?.course) {
         return lesson.amends.course;
       }
       return undefined;
diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
index 7f9d9eea..4f2d554f 100644
--- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
+++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
@@ -183,18 +183,10 @@ import deleteMixin from "aleksis.core/mixins/deleteMixin.js";
         :value="substitution.cancelled"
         @change="save"
       >
-        <v-btn
-          outlined
-          :value="false"
-          @click="cancelled = false"
-        >
+        <v-btn outlined :value="false" @click="cancelled = false">
           {{ $t("chronos.substitutions.overview.cancel.not_cancelled") }}
         </v-btn>
-        <v-btn
-          outlined
-          :value="true"
-          @click="cancelled = true"
-        >
+        <v-btn outlined :value="true" @click="cancelled = true">
           {{ $t("chronos.substitutions.overview.cancel.cancelled") }}
         </v-btn>
       </v-btn-toggle>
@@ -269,7 +261,9 @@ export default {
       return this.roomsWithStatus.find((r) => r.id === room.id)?.status;
     },
     removeTeacher(teacher) {
-      this.teachers = this.substitutionTeacherIDs.filter((t) => t !== teacher.id);
+      this.teachers = this.substitutionTeacherIDs.filter(
+        (t) => t !== teacher.id,
+      );
       this.save(true);
     },
     removeRoom(room) {
@@ -297,17 +291,21 @@ export default {
         this.teachers.length ||
         this.rooms.length ||
         this.substitutionSubject !== null ||
-        (this.comment !== null &&
-        this.comment !== "") ||
+        (this.comment !== null && this.comment !== "") ||
         this.cancelled !== null
       ) {
         this.createOrPatch([
           {
             id: this.substitution.id,
-            ...((allowEmpty || this.teachers.length) && { teachers: this.teachers }),
+            ...((allowEmpty || this.teachers.length) && {
+              teachers: this.teachers,
+            }),
             ...((allowEmpty || this.rooms.length) && { rooms: this.rooms }),
-            ...(this.substitutionSubject !== null && { subject: this.substitutionSubject }),
-            ...((this.comment !== null && this.comment !== "") && { comment: this.comment }),
+            ...(this.substitutionSubject !== null && {
+              subject: this.substitutionSubject,
+            }),
+            ...(this.comment !== null &&
+              this.comment !== "" && { comment: this.comment }),
             ...(this.cancelled !== null && { cancelled: this.cancelled }),
           },
         ]);
@@ -379,11 +377,9 @@ export default {
     subject() {
       if (this.substitution.subject) {
         return this.substitution.subject;
-      }
-      else if (this.substitution.course?.subject) {
+      } else if (this.substitution.course?.subject) {
         return this.substitution.course.subject;
-      }
-      else if (this.substitution.amends?.subject) {
+      } else if (this.substitution.amends?.subject) {
         return this.substitution.amends.subject;
       }
       return undefined;
diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
index e86d8ec6..50fcb5d7 100644
--- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
+++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
@@ -42,8 +42,7 @@ export default {
     course() {
       if (this.substitution.course) {
         return this.substitution.course;
-      }
-      else if (this.substitution.amends?.course) {
+      } else if (this.substitution.amends?.course) {
         return this.substitution.amends.course;
       }
       return undefined;
diff --git a/aleksis/apps/chronos/frontend/index.js b/aleksis/apps/chronos/frontend/index.js
index 2a76a198..fee33a13 100644
--- a/aleksis/apps/chronos/frontend/index.js
+++ b/aleksis/apps/chronos/frontend/index.js
@@ -46,7 +46,8 @@ export default {
     },
     {
       path: "substitution_overview/",
-      component: () => import("./components/substitutions/SubstitutionOverview.vue"),
+      component: () =>
+        import("./components/substitutions/SubstitutionOverview.vue"),
       redirect: () => {
         return {
           path: "substitution_overview/group/all/person/all/",
@@ -66,7 +67,8 @@ export default {
       children: [
         {
           path: "group/:objId(all|\\d+)?/person/:teacherId(all|\\d+)?/",
-          component: () => import("./components/substitutions/SubstitutionOverview.vue"),
+          component: () =>
+            import("./components/substitutions/SubstitutionOverview.vue"),
           name: "chronos.substitutionOverview",
           meta: {
             titleKey: "chronos.substitutions.overview.menu_title",
diff --git a/aleksis/apps/chronos/models.py b/aleksis/apps/chronos/models.py
index 767c9681..f710b3a7 100644
--- a/aleksis/apps/chronos/models.py
+++ b/aleksis/apps/chronos/models.py
@@ -1624,17 +1624,18 @@ class LessonEvent(CalendarEvent):
         date_start: datetime,
         date_end: datetime,
         request: HttpRequest,
-        obj_type: Optional[str],
-        obj_id: Optional[str],
-        teacher: Optional[str],
-        incomplete: Optional[bool] = False,
+        obj_type: str | None = None,
+        obj_id: str | None = None,
+        teacher: str | None = None,
+        incomplete: str | None = False,
     ) -> list:
         """Get all the amended lessons for an object and a time frame.
 
         obj_type may be one of TEACHER, GROUP, ROOM, COURSE
         """
 
-        # 1. Find all LessonEvents for all Lessons of this Group in this date range and which are not themselves amending another lessonEvent
+        # 1. Find all LessonEvents for all Lessons of this Group in this date range
+        # which are not themselves amending another lessonEvent
         event_params = {
             "not_amending": True,
             "prefetch_absences": True,
@@ -1672,11 +1673,16 @@ class LessonEvent(CalendarEvent):
             event_queryset = event_queryset.for_teachers(affected_teachers)
 
         events = LessonEvent.get_single_events(
-            start=date_start, end=date_end, request=request, with_reference_object=True, queryset=event_queryset
+            start=date_start,
+            end=date_end,
+            request=request,
+            with_reference_object=True,
+            queryset=event_queryset,
         )
 
-        # 2. For each lessonEvent → check if there are any teachers with absences that overlap the lesson & if yes, check if there is already an amendment for that lesson
-        # if so, add it to a list, if not, create a dummy one
+        # 2. For each lessonEvent → check if there are any teachers with absences that overlap
+        # the lesson & if yes, check if there is already an amendment for that lesson
+        # If so, add it to a list, if not, create a dummy one
 
         substitutions = []
 
diff --git a/aleksis/apps/chronos/rules.py b/aleksis/apps/chronos/rules.py
index f5a4bb30..ad9e8365 100644
--- a/aleksis/apps/chronos/rules.py
+++ b/aleksis/apps/chronos/rules.py
@@ -12,8 +12,8 @@ from .util.predicates import (
     has_any_group_substitution_perm,
     has_any_timetable_object,
     has_group_substitution_perm,
-    has_substitution_perm_by_group,
     has_room_timetable_perm,
+    has_substitution_perm_by_group,
     has_timetable_perm,
 )
 
@@ -36,15 +36,13 @@ add_perm("chronos.view_lessons_day_rule", view_lessons_day_predicate)
 
 # View substitution management overview page
 view_substitution_overview_predicate = has_person & (
-    has_global_perm("chronos.manage_substitutions")
-    | has_any_group_substitution_perm
+    has_global_perm("chronos.manage_substitutions") | has_any_group_substitution_perm
 )
 add_perm("chronos.view_substitution_overview_rule", view_substitution_overview_predicate)
 
 # Manage substitutions for a group
 manage_substitutions_for_group_predicate = has_person & (
-    has_global_perm("chronos.manage_substitutions")
-    | has_group_substitution_perm
+    has_global_perm("chronos.manage_substitutions") | has_group_substitution_perm
 )
 add_perm("chronos.manage_substitutions_for_group_rule", manage_substitutions_for_group_predicate)
 
diff --git a/aleksis/apps/chronos/schema/__init__.py b/aleksis/apps/chronos/schema/__init__.py
index 8de72069..6f983e9c 100644
--- a/aleksis/apps/chronos/schema/__init__.py
+++ b/aleksis/apps/chronos/schema/__init__.py
@@ -1,23 +1,20 @@
-from datetime import date, datetime, timezone
+from datetime import datetime
 
-from functools import reduce
-from operator import and_
 from django.core.exceptions import PermissionDenied
-from django.db.models import F, ManyToManyField, OuterRef, Subquery, Q, Prefetch
+from django.db.models import Q
 
 import graphene
 from graphene_django import DjangoObjectType
 from reversion import create_revision, set_comment, set_user
 
-from aleksis.core.models import CalendarEvent, Group, Person, Room
+from aleksis.apps.cursus.models import Subject
+from aleksis.core.models import Group, Person, Room
 from aleksis.core.schema.base import (
     BaseBatchCreateMutation,
     BaseBatchDeleteMutation,
     BaseBatchPatchMutation,
-    DeleteMutation,
     FilterOrderList,
 )
-from aleksis.apps.cursus.models import Subject
 
 from ..models import LessonEvent
 from ..util.chronos_helpers import get_groups, get_rooms, get_teachers
@@ -300,7 +297,15 @@ class Query(graphene.ObjectType):
         return all_timetables
 
     def resolve_amended_lessons_from_absences(
-        root, info, date_start, date_end, obj_type="GROUP", obj_id=None, teacher=None, incomplete=False, **kwargs
+        root,
+        info,
+        date_start,
+        date_end,
+        obj_type="GROUP",
+        obj_id=None,
+        teacher=None,
+        incomplete=False,
+        **kwargs,
     ):
         datetime_start = datetime.combine(date_start, datetime.min.time())
         datetime_end = datetime.combine(date_end, datetime.max.time())
diff --git a/aleksis/apps/chronos/util/predicates.py b/aleksis/apps/chronos/util/predicates.py
index a5aac786..0a07b5e9 100644
--- a/aleksis/apps/chronos/util/predicates.py
+++ b/aleksis/apps/chronos/util/predicates.py
@@ -7,8 +7,8 @@ from aleksis.core.models import Group, Person, Room
 from aleksis.core.util.core_helpers import queryset_rules_filter
 from aleksis.core.util.predicates import has_any_object, has_global_perm, has_object_perm
 
-from .chronos_helpers import get_groups, get_rooms, get_teachers
 from ..models import LessonEvent
+from .chronos_helpers import get_groups, get_rooms, get_teachers
 
 
 @predicate
-- 
GitLab