From a29a17d99b807f37d2eac92a6745b53955207f36 Mon Sep 17 00:00:00 2001 From: Julian Leucker <leuckerj@gmail.com> Date: Tue, 18 Jun 2024 14:54:16 +0200 Subject: [PATCH] Send tardinesses to frontend --- .../absences/participationStatus.graphql | 4 ++++ .../components/coursebook/coursebook.graphql | 4 ++++ .../personal_notes/personal_notes.graphql | 3 +++ .../apps/alsijil/schema/participation_status.py | 15 ++++++++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/absences/participationStatus.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/absences/participationStatus.graphql index 61c486a70..abc66fe17 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/absences/participationStatus.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/absences/participationStatus.graphql @@ -46,6 +46,10 @@ mutation touchDocumentation($documentationId: ID!) { id note } + noteWithTardiness { + id + tardiness + } isOptimistic } } diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/coursebook.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/coursebook.graphql index 2505ee24b..985fa3ace 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/coursebook.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/coursebook.graphql @@ -90,6 +90,10 @@ query documentationsForCoursebook( id note } + noteWithTardiness { + id + tardiness + } isOptimistic } topic diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/personal_notes.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/personal_notes.graphql index 014178c13..d5544e3e9 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/personal_notes.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/personal_notes.graphql @@ -5,6 +5,7 @@ query personalNotes($orderBy: [String], $filters: JSONString) { extraMark { id } + tardiness canEdit canDelete } @@ -18,6 +19,7 @@ mutation createPersonalNotes($input: [BatchCreatePersonalNoteInput]!) { extraMark { id } + tardiness canEdit canDelete } @@ -38,6 +40,7 @@ mutation updatePersonalNotes($input: [BatchPatchPersonalNoteInput]!) { extraMark { id } + tardiness canEdit canDelete } diff --git a/aleksis/apps/alsijil/schema/participation_status.py b/aleksis/apps/alsijil/schema/participation_status.py index ddff69e7c..173ddeaab 100644 --- a/aleksis/apps/alsijil/schema/participation_status.py +++ b/aleksis/apps/alsijil/schema/participation_status.py @@ -31,6 +31,7 @@ class ParticipationStatusType( notes_with_extra_mark = graphene.List(PersonalNoteType) notes_with_note = graphene.List(PersonalNoteType) + note_with_tardiness = graphene.Field(PersonalNoteType(), required=False) @staticmethod def resolve_notes_with_extra_mark(root: ParticipationStatus, info, **kwargs): @@ -45,9 +46,21 @@ class ParticipationStatusType( return NewPersonalNote.objects.filter( person=root.person, documentation=root.related_documentation, - extra_mark__isnull=True, + note__isnull=False, ) + @staticmethod + def resolve_note_with_tardiness(root: ParticipationStatus, info, **kwargs): + notes = NewPersonalNote.objects.filter( + person=root.person, + documentation=root.related_documentation, + tardiness__isnull=False, + ) + if len(notes): + return notes.first() + + return None + class ParticipationStatusBatchPatchMutation(BaseBatchPatchMutation): class Meta: -- GitLab