diff --git a/aleksis/apps/alsijil/schema.py b/aleksis/apps/alsijil/schema.py index df025b11c054a268b5b2675af0d1f805ce020dcf..63cc90717ef4383e78424a4ba99ab20ec1d67a96 100644 --- a/aleksis/apps/alsijil/schema.py +++ b/aleksis/apps/alsijil/schema.py @@ -82,16 +82,13 @@ class PersonalNoteMutation(graphene.Mutation): person_id, lesson_documentation, personal_note_id=None, - late=0, - absent=False, - excused=False, + late=None, + absent=None, + excused=None, excuse_type=None, - remarks="", + remarks=None, extra_marks=None ): - if extra_marks is None: - extra_marks = [] - person = Person.objects.get(pk=person_id) lesson_documentation = LessonDocumentation.objects.get(pk=lesson_documentation) @@ -103,22 +100,26 @@ class PersonalNoteMutation(graphene.Mutation): week=lesson_documentation.week, year=lesson_documentation.year, ) - if late: + if late is not None: personal_note.late = late if absent is not None: personal_note.absent = absent if excused is not None: personal_note.excused = excused - if excuse_type: + if excuse_type is not None: personal_note.excuse_type = ExcuseType.objects.get(pk=excuse_type) - if remarks: + if remarks is not None: personal_note.remarks = remarks - personal_note.save() - extra_marks = ExtraMark.objects.filter(pk__in=extra_marks) - personal_note.extra_marks.set(extra_marks) - personal_note.groups_of_person.set(person.member_of.all()) + if created: + personal_note.groups_of_person.set(person.member_of.all()) + personal_note.save() + + if extra_marks is not None: + extra_marks = ExtraMark.objects.filter(pk__in=extra_marks) + personal_note.extra_marks.set(extra_marks) + personal_note.save() return PersonalNoteMutation(personal_note=personal_note)