Skip to content
Snippets Groups Projects
Commit 3bf4cb9c authored by Julian's avatar Julian
Browse files

Create schema to update lesson documentations and personal notes

parent 71b71242
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment