From 621b9b318410f09d972fe042ba96f822f78bf2ce Mon Sep 17 00:00:00 2001 From: Hangzhi Yu <hangzhi@protonmail.com> Date: Wed, 22 May 2024 13:07:50 +0200 Subject: [PATCH] Reformat --- .../substitutions/SubstitutionCard.vue | 20 ++++++------------- .../substitutions/SubstitutionInformation.vue | 2 +- .../substitutions/SubstitutionStatus.vue | 1 - aleksis/apps/chronos/managers.py | 20 ++++++++----------- aleksis/apps/chronos/util/predicates.py | 7 +++---- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue index a3167a45..7076ac91 100644 --- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue +++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue @@ -49,9 +49,7 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js"; > <template #prepend-inner> <v-chip - v-if="roomsWithStatus.filter( - (t) => t.status === 'regular', - ).length" + v-if="roomsWithStatus.filter((t) => t.status === 'regular').length" v-for="room in roomsWithStatus.filter( (t) => t.status === 'regular', )" @@ -61,9 +59,7 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js"; {{ room.shortName }} </v-chip> <v-chip - v-if="roomsWithStatus.filter( - (t) => t.status === 'removed', - ).length" + v-if="roomsWithStatus.filter((t) => t.status === 'removed').length" v-for="room in roomsWithStatus.filter( (t) => t.status === 'removed', )" @@ -90,9 +86,7 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js"; color="success" @click:close="removeRoom(data.item)" > - <v-icon left> - mdi-plus-circle-outline - </v-icon> + <v-icon left> mdi-plus-circle-outline </v-icon> {{ data.item.shortName ? data.item.shortName : data.item.name }} </v-chip> </template> @@ -246,11 +240,11 @@ export default { this.teachers = teachers; this.save(); }, - roomsInput(rooms){ + roomsInput(rooms) { this.rooms = rooms; this.save(); }, - cancelledInput(cancelled){ + cancelledInput(cancelled) { this.cancelled = cancelled; this.save(); }, @@ -307,9 +301,7 @@ export default { return teachersWithStatus; }, roomsWithStatus() { - const oldIds = this.substitution.amends.rooms.map( - (room) => room.id, - ); + const oldIds = this.substitution.amends.rooms.map((room) => room.id); const newIds = this.substitution.rooms.map((room) => room.id); const allRooms = new Set( this.substitution.amends.rooms.concat(this.substitution.rooms), diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue index 2af9d1cb..82eca3c9 100644 --- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue +++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue @@ -9,7 +9,7 @@ import { DateTime } from "luxon"; <template> <div class="full-width grid"> <div class="d-flex"> - <substitution-status :substitution="substitution"/> + <substitution-status :substitution="substitution" /> <div class="text-right d-flex flex-column fit-content"> <time :datetime="substitution.datetimeStart" class="text-no-wrap"> {{ $d(toDateTime(substitution.datetimeStart), "shortTime") }} diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionStatus.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionStatus.vue index 13eb3bc6..2ffeab5a 100644 --- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionStatus.vue +++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionStatus.vue @@ -14,7 +14,6 @@ </template> <script> - import { DateTime } from "luxon"; export default { diff --git a/aleksis/apps/chronos/managers.py b/aleksis/apps/chronos/managers.py index 532e49cc..ebda7f1e 100644 --- a/aleksis/apps/chronos/managers.py +++ b/aleksis/apps/chronos/managers.py @@ -878,21 +878,17 @@ class LessonEventQuerySet(PolymorphicQuerySet): def for_participant(self, person: Union[int, Person]) -> "LessonEventQuerySet": """Get all lesson events the person participates in (including amends).""" - amended = self.filter( - Q(amended_by__isnull=False) | Q(groups__members=person) - ).values_list("amended_by__pk", flat=True) - return self.filter( - Q(groups__members=person) | Q(pk__in=amended) - ).distinct() + amended = self.filter(Q(amended_by__isnull=False) | Q(groups__members=person)).values_list( + "amended_by__pk", flat=True + ) + return self.filter(Q(groups__members=person) | Q(pk__in=amended)).distinct() def for_owner(self, person: Union[int, Person]) -> "LessonEventQuerySet": """Get all lesson events the person owns any group of (including amends).""" - amended = self.filter( - Q(amended_by__isnull=False) | Q(groups__owners=person) - ).values_list("amended_by__pk", flat=True) - return self.filter( - Q(groups__owners=person) | Q(pk__in=amended) - ).distinct() + amended = self.filter(Q(amended_by__isnull=False) | Q(groups__owners=person)).values_list( + "amended_by__pk", flat=True + ) + return self.filter(Q(groups__owners=person) | Q(pk__in=amended)).distinct() def for_group(self, group: Union[int, Group]) -> "LessonEventQuerySet": """Get all lesson events for a certain group (including amends/as parent group).""" diff --git a/aleksis/apps/chronos/util/predicates.py b/aleksis/apps/chronos/util/predicates.py index f9103c12..a5aac786 100644 --- a/aleksis/apps/chronos/util/predicates.py +++ b/aleksis/apps/chronos/util/predicates.py @@ -83,10 +83,9 @@ def has_any_group_substitution_perm(user: User) -> bool: Predicate which checks whether the user is allowed to create/edit any substitutions of any group. """ - return ( - user.person.owner_of.exists() - or has_any_object("core.manage_group_substitutions", Group)(user) - ) + return user.person.owner_of.exists() or has_any_object( + "core.manage_group_substitutions", Group + )(user) @predicate -- GitLab