From 3bf4cb9c9ffe104255a138dec2cb3f929157f54c Mon Sep 17 00:00:00 2001
From: Julian Leucker <leuckerj@gmail.com>
Date: Mon, 18 Jul 2022 18:32:14 +0200
Subject: [PATCH] Create schema to update lesson documentations and personal
 notes

---
 aleksis/apps/alsijil/schema.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/aleksis/apps/alsijil/schema.py b/aleksis/apps/alsijil/schema.py
index f18f23e39..1333d147f 100644
--- a/aleksis/apps/alsijil/schema.py
+++ b/aleksis/apps/alsijil/schema.py
@@ -4,7 +4,7 @@ from graphene_django.forms.mutation import DjangoModelFormMutation
 
 from aleksis.apps.chronos.models import LessonPeriod
 from aleksis.core.models import Person, Group
-from .forms import LessonDocumentationForm
+from .forms import LessonDocumentationForm, PersonalNoteForm
 from .models import ExcuseType, LessonDocumentation, PersonalNote, ExtraMark
 
 
@@ -58,9 +58,22 @@ class LessonDocumentationMutation(DjangoModelFormMutation):
         form_class = LessonDocumentationForm
 
 
+class PersonalNoteMutation(DjangoModelFormMutation):
+    personal_note = graphene.Field(PersonalNoteType)
+
+    class Meta:
+        form_class = PersonalNoteForm
+
+
+class Mutation(graphene.ObjectType):
+    update_lesson_documentation = LessonDocumentationMutation.Field()
+    update_personal_note = PersonalNoteMutation.Field()
+
+
 class Query(graphene.ObjectType):
     excuse_types = graphene.List(ExcuseTypeType)
     lesson_documentations = graphene.List(LessonDocumentationType)
+    lesson_documentation_by_id = graphene.Field(LessonDocumentationType, id=graphene.ID())
     lesson_documentations_by_lesson_id = graphene.List(LessonDocumentationType, id=graphene.ID())
     personal_notes = graphene.List(PersonalNoteType)
     extra_marks = graphene.List(ExtraMarkType)
@@ -74,6 +87,9 @@ class Query(graphene.ObjectType):
         return LessonDocumentation.objects.all().order_by("-year", "-week", "-lesson_period__period__weekday",
                                                           "-lesson_period__period__period")
 
+    def resolve_lesson_documentation_by_id(root, info, id, **kwargs):
+        return LessonDocumentation.objects.get(id=id)
+
     def resolve_lesson_documentations_by_lesson_id(root, info, id, **kwargs):
         return LessonDocumentation.objects.filter(
             lesson_period_id__in=LessonPeriod.objects.filter(
-- 
GitLab