diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/absences/ManageStudentsDialog.vue b/aleksis/apps/alsijil/frontend/components/coursebook/absences/ManageStudentsDialog.vue index 1fdbd333e2fc21fb44470382e515159e1bc743fe..c165cec1f90b936cba67b583564badd0aa6cd92c 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/absences/ManageStudentsDialog.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/absences/ManageStudentsDialog.vue @@ -8,10 +8,7 @@ import MobileFullscreenDialog from "aleksis.core/components/generic/dialogs/Mobi import updateParticipationMixin from "./updateParticipationMixin.js"; import deepSearchMixin from "aleksis.core/mixins/deepSearchMixin.js"; import LessonInformation from "../documentation/LessonInformation.vue"; -import { - extendParticipationStatuses, - updateParticipationStatuses, -} from "./participationStatus.graphql"; +import { extendParticipationStatuses } from "./participationStatus.graphql"; import SlideIterator from "aleksis.core/components/generic/SlideIterator.vue"; import PersonalNotes from "../personal_notes/PersonalNotes.vue"; import PersonalNoteChip from "../personal_notes/PersonalNoteChip.vue"; diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsAbsencesCard.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsAbsencesCard.vue index fb8d90a6a8fe80c368f286f9f78bf9e07f1d3e0e..8be29a0a2216a215351c2ebf984e2fdbae3d00ad 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsAbsencesCard.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsAbsencesCard.vue @@ -5,7 +5,7 @@ <absence-reason-chip v-for="absenceReason in absenceReasons" :key="absenceReason.id" - :absenceReason="absenceReason.absenceReason" + :absence-reason="absenceReason.absenceReason" :count="absenceReason.count" /> </v-card-text> diff --git a/aleksis/apps/alsijil/frontend/index.js b/aleksis/apps/alsijil/frontend/index.js index ac475483e76e9538c36ffb55d85f53c6531ec802..fe222f4fee3fcc28ad93448b4482babcf0ab32cf 100644 --- a/aleksis/apps/alsijil/frontend/index.js +++ b/aleksis/apps/alsijil/frontend/index.js @@ -1,4 +1,3 @@ -import { hasPersonValidator } from "aleksis.core/routeValidators"; import { DateTime } from "luxon"; import { MODE } from "./components/coursebook/statistics/modes"; diff --git a/aleksis/apps/alsijil/managers.py b/aleksis/apps/alsijil/managers.py index b8d17a7aa95c34fd7d87314d37da943844a64771..681e3e562be5f8b26c4fd31fb543dcadbbe5fb29 100644 --- a/aleksis/apps/alsijil/managers.py +++ b/aleksis/apps/alsijil/managers.py @@ -1,5 +1,6 @@ +from collections.abc import Sequence from datetime import date, datetime -from typing import TYPE_CHECKING, Optional, Sequence, Union +from typing import TYPE_CHECKING, Optional, Union from django.db.models import QuerySet from django.db.models.query import Prefetch diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index 7e10a80cb0f83f065d94198658d13c9bc3acfe30..2dd3deac4fbc03f3e85b4d791170f09eaf5054e3 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import List, Optional +from typing import Optional from django.contrib.auth.models import User from django.core.exceptions import PermissionDenied @@ -117,7 +117,7 @@ class Documentation(CalendarEvent): if self.course: return self.course.groups.all() - def get_teachers_short_names(self) -> List[str]: + def get_teachers_short_names(self) -> list[str]: return [teacher.short_name or teacher.name for teacher in self.teachers.all()] def __str__(self) -> str: diff --git a/aleksis/apps/alsijil/schema/absences.py b/aleksis/apps/alsijil/schema/absences.py index 28eca0172e7caf203214d6db27eee5c31d6c0b09..eea8b075b3e1ba2a0e6011e4b7e33e6df4f09ed4 100644 --- a/aleksis/apps/alsijil/schema/absences.py +++ b/aleksis/apps/alsijil/schema/absences.py @@ -1,5 +1,4 @@ import datetime -from typing import List from django.core.exceptions import PermissionDenied @@ -28,7 +27,7 @@ class AbsencesForPersonsCreateMutation(graphene.Mutation): cls, root, info, - persons: List[str | int], + persons: list[str | int], start: datetime.datetime, end: datetime.datetime, comment: str, diff --git a/aleksis/apps/alsijil/tasks.py b/aleksis/apps/alsijil/tasks.py index 2502658defa8da7ecb68e9be7fbb606da7de9632..5c0377d7468a56dd6539c18c8ea80e15b69738b6 100644 --- a/aleksis/apps/alsijil/tasks.py +++ b/aleksis/apps/alsijil/tasks.py @@ -1,5 +1,5 @@ from datetime import date -from typing import List, Optional +from typing import Optional from django.db.models import Prefetch, Q from django.utils.translation import gettext as _ @@ -19,7 +19,7 @@ from .models import Documentation, ExtraMark, NewPersonalNote, ParticipationStat @recorded_task def generate_full_register_printout( - groups: List[int], + groups: list[int], file_object: int, recorder: ProgressRecorder, include_cover: Optional[bool] = True, @@ -142,9 +142,7 @@ def generate_full_register_printout( group.as_list = [group] if include_coursebook: - group.documentations = documentations.order_by( - "datetime_start" - ).prefetch_related( + group.documentations = documentations.order_by("datetime_start").prefetch_related( prefetch_notable_participations(select_related=["person"]), prefetch_personal_notes("personal_notes", select_related=["person"]), ) diff --git a/aleksis/apps/alsijil/util/predicates.py b/aleksis/apps/alsijil/util/predicates.py index 7177034281562b2aae4d9983f70def95f4a1c75a..0afb920046c24e03e431950d610b2687467eb16c 100644 --- a/aleksis/apps/alsijil/util/predicates.py +++ b/aleksis/apps/alsijil/util/predicates.py @@ -22,10 +22,7 @@ def is_group_owner(user: User, obj: Union[Group, Person]) -> bool: Checks whether the person linked to the user is the owner of the given group. If there isn't provided a group, it will return `False`. """ - if isinstance(obj, Group) and user.person in obj.owners.all(): - return True - - return False + return bool(isinstance(obj, Group) and user.person in obj.owners.all()) @predicate @@ -88,10 +85,7 @@ def is_group_member(user: User, obj: Union[Group, Person]) -> bool: Checks whether the person linked to the user is a member of the given group. If there isn't provided a group, it will return `False`. """ - if isinstance(obj, Group) and user.person in obj.members.all(): - return True - - return False + return bool(isinstance(obj, Group) and user.person in obj.members.all()) @predicate @@ -252,14 +246,13 @@ def can_view_any_documentation(user: User): if allowed_lesson_events.exists(): return True - if Documentation.objects.filter( - Q(teachers=user.person) - | Q(amends__in=allowed_lesson_events) - | Q(course__teachers=user.person) - ).exists(): - return True - - return False + return bool( + Documentation.objects.filter( + Q(teachers=user.person) + | Q(amends__in=allowed_lesson_events) + | Q(course__teachers=user.person) + ).exists() + ) @predicate @@ -316,27 +309,22 @@ def is_in_allowed_time_range(user: User, obj: Union[Documentation, NewPersonalNo """ if isinstance(obj, NewPersonalNote): obj = obj.documentation - if obj and ( - get_site_preferences()["alsijil__allow_edit_future_documentations"] == "all" - or ( - get_site_preferences()["alsijil__allow_edit_future_documentations"] == "current_day" + return bool( + obj + and ( + get_site_preferences()["alsijil__allow_edit_future_documentations"] == "all" + or get_site_preferences()["alsijil__allow_edit_future_documentations"] == "current_day" and obj.value_start_datetime(obj).date() <= localdate() - ) - or ( - get_site_preferences()["alsijil__allow_edit_future_documentations"] == "current_time" + or get_site_preferences()["alsijil__allow_edit_future_documentations"] == "current_time" and obj.value_start_datetime(obj) <= now() ) - ): - return True - return False + ) @predicate def is_in_allowed_time_range_for_participation_status(user: User, obj: Documentation): """Predicate which checks if the documentation is in the allowed time range for editing.""" - if obj and obj.value_start_datetime(obj) <= now(): - return True - return False + return bool(obj and obj.value_start_datetime(obj) <= now()) @predicate diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index c48c13eea04af8ab0c205ba851717a936cfe50a6..71b4cbdd6ee85c3eb280c9f15549e31736b060ab 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any from django.core.exceptions import BadRequest, PermissionDenied from django.db.models import Q @@ -146,7 +146,7 @@ class AssignedGroupRolesView(PermissionRequiredMixin, DetailView): model = Group template_name = "alsijil/group_role/assigned_list.html" - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: context = super().get_context_data() today = timezone.now().date() @@ -190,7 +190,7 @@ class AssignGroupRoleView(PermissionRequiredMixin, SuccessNextMixin, AdvancedCre kwargs["initial"] = {"role": self.role, "groups": [self.group]} return kwargs - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: + def get_context_data(self, **kwargs: Any) -> dict[str, Any]: context = super().get_context_data(**kwargs) context["role"] = self.role context["group"] = self.group