From d0dc97e9d5d17d8a66074fb78132535f629d01f1 Mon Sep 17 00:00:00 2001 From: Julian Leucker <leuckerj@gmail.com> Date: Mon, 28 Oct 2024 14:17:23 +0100 Subject: [PATCH] Drop DocumentationByPersonType --- aleksis/apps/alsijil/schema/__init__.py | 29 +++++++++++------ aleksis/apps/alsijil/schema/statistics.py | 39 ----------------------- 2 files changed, 19 insertions(+), 49 deletions(-) diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 06c2615ca..ab2df1d2d 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -17,7 +17,7 @@ from aleksis.core.schema.person import PersonType from aleksis.core.util.core_helpers import get_site_preferences, has_person from ..model_extensions import annotate_person_statistics_for_school_term -from ..models import Documentation +from ..models import Documentation, ParticipationStatus, NewPersonalNote from .absences import ( AbsencesForPersonsCreateMutation, ) @@ -36,16 +36,15 @@ from .extra_marks import ( from .participation_status import ( ExtendParticipationStatusToAbsenceBatchMutation, ParticipationStatusBatchPatchMutation, + ParticipationStatusType, ) from .personal_note import ( PersonalNoteBatchCreateMutation, PersonalNoteBatchDeleteMutation, PersonalNoteBatchPatchMutation, + PersonalNoteType, ) -from .statistics import ( - DocumentationByPersonType, - StatisticsByPersonType, -) +from .statistics import StatisticsByPersonType class Query(graphene.ObjectType): @@ -84,8 +83,13 @@ class Query(graphene.ObjectType): person=graphene.ID(required=True), term=graphene.ID(required=True), ) - documentations_by_person = graphene.List( - DocumentationByPersonType, + participations_of_person = graphene.List( + ParticipationStatusType, + person=graphene.ID(required=True), + term=graphene.ID(required=False), + ) + personal_notes_for_person = graphene.List( + PersonalNoteType, person=graphene.ID(required=True), term=graphene.ID(required=False), ) @@ -261,9 +265,14 @@ class Query(graphene.ObjectType): ).first() @staticmethod - def resolve_documentations_by_person(root, info, person, term=None): - # TODO: Annotate person with necessary information for term. - return Person.objects.filter(id=person) + def resolve_participations_of_person(root, info, person, term=None): + # TODO: only current term + return ParticipationStatus.objects.filter(person=person, absence_reason__isnull=False) + + @staticmethod + def resolve_personal_notes_for_person(root, info, person, term=None): + # TODO: only current term + return NewPersonalNote.objects.filter(person=person) @staticmethod def resolve_statistics_by_group(root, info, group, term=None): diff --git a/aleksis/apps/alsijil/schema/statistics.py b/aleksis/apps/alsijil/schema/statistics.py index edf15c909..976f25ebb 100644 --- a/aleksis/apps/alsijil/schema/statistics.py +++ b/aleksis/apps/alsijil/schema/statistics.py @@ -65,42 +65,3 @@ class StatisticsByPersonType(graphene.ObjectType): dict(extra_mark=extra_mark, count=getattr(root, extra_mark.count_label)) for extra_mark in ExtraMark.objects.all() ] - - -class DocumentationByPersonType(graphene.ObjectType): - id = graphene.ID() - datetime_start = graphene.Date() - datetime_end = graphene.Date() - group_short_name = graphene.String() - teacher = graphene.Field(PersonType) - subject = graphene.Field(SubjectType) - absences = graphene.List(AbsenceReasonType) - extra_marks = graphene.List(ExtraMarkType) - personal_note = graphene.String() - - def resolve_id(root, info): - return 1 - - def resolve_datetime_start(root, info): - return timezone.now().replace(2024, 5, 27, 9, 0) - - def resolve_datetime_end(root, info): - return timezone.now().replace(2024, 5, 27, 10, 0) - - def resolve_group_short_name(root, info): - return "11b" - - def resolve_teacher(root, info): - return Person.objects.last() - - def resolve_subject(root, info): - return Subject.objects.first() - - def resolve_absences(root, info): - return AbsenceReason.objects.all() - - def resolve_extra_marks(root, info): - return ExtraMark.objects.all() - - def resolve_personal_note(root, info): - return "All is well:)" -- GitLab