diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 06c2615ca727fc3c38191f3dfa037a76b1bbedee..ab2df1d2d6a63a116ce1bc53038b0ce049c2f75d 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 edf15c9097ef5e9d328f4315bb3ff781097449e5..976f25ebb32b50c9152fb86d23acf17011d7a89f 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:)"