Skip to content
Snippets Groups Projects
Commit c04c78f9 authored by permcu's avatar permcu Committed by Julian
Browse files

Sketch backend

parent 02e23a8e
No related branches found
No related tags found
1 merge request!360Resolve "Add absence management to course book student dialog"
...@@ -38,6 +38,13 @@ class Query(graphene.ObjectType): ...@@ -38,6 +38,13 @@ class Query(graphene.ObjectType):
groups_by_person = FilterOrderList(GroupType, person=graphene.ID()) groups_by_person = FilterOrderList(GroupType, person=graphene.ID())
courses_of_person = FilterOrderList(CourseType, person=graphene.ID()) courses_of_person = FilterOrderList(CourseType, person=graphene.ID())
lesson_events_for_absences = FilterOrderList(
PersonAbsencesType??,
persons=graphene.List(graphene.ID, required=True),
start=graphene.Date(required=True),
end=graphene.Date(required=True),
)
def resolve_documentations_by_course_id(root, info, course_id, **kwargs): def resolve_documentations_by_course_id(root, info, course_id, **kwargs):
documentations = Documentation.objects.filter( documentations = Documentation.objects.filter(
Q(course__pk=course_id) | Q(amends__course__pk=course_id) Q(course__pk=course_id) | Q(amends__course__pk=course_id)
...@@ -117,7 +124,35 @@ class Query(graphene.ObjectType): ...@@ -117,7 +124,35 @@ class Query(graphene.ObjectType):
| Q(groups__parent_groups__owners=person) | Q(groups__parent_groups__owners=person)
) )
def lesson_events_for_absences(
root,
info,
persons,
start,
end,
**kwargs,
):
# Do date like resolve_documentations_for_coursebook?
# Get all lesson events for person
# Make this reusable for mutation
# Pack into (id fullname lesson (start end course subject ...))
event_params = {
""
}
events = LessonEvent.get_single_events(
start,
end,
request??,
event_params,
with_reference_object=True,
)
return
class Mutation(graphene.ObjectType): class Mutation(graphene.ObjectType):
create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field() create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field()
create_absences = AbsencesBatchCreateMutation.Field()
update_participation_statuses = ParticipationStatusBatchPatchMutation.Field() update_participation_statuses = ParticipationStatusBatchPatchMutation.Field()
import graphene
class AbsencesBatchCreateMutation(graphene.Mutation):
class Arguments:
persons = graphene.List(graphene.ID)
start = graphene.Date(),
end = graphene.Date(),
comment = graphene.String(),
reason = graphene.ID()
ok = graphene.Boolean()
@classmethod
def mutate(cls, root, info, input): # noqa
# Get all lesson events for person (share with query)
# Look up documentations for lesson events
# (share with models.py Documentation get_for_coursebook;
# has lesson event lookup as well & returns real & fake documentations
# => extract & reuse the documentation lookup)
# Create a ParticipationStatus for each documentation
# If there are any LessonEvents without a documentation
# create a Kolego Absence for the whole duration
# Return ok=True if everything went well.
return AbsencesBatchCreateMutation(ok=BOOL)
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