Skip to content
Snippets Groups Projects
Verified Commit 1fb685a1 authored by permcu's avatar permcu Committed by Jonathan Weth
Browse files

Resolve substitutions partially via graphene-types

parent caf5613e
No related branches found
No related tags found
1 merge request!373Resolve "Substitutions table for new data model"
...@@ -9,15 +9,18 @@ query substitutionsForDate ($date: Date!) { ...@@ -9,15 +9,18 @@ query substitutionsForDate ($date: Date!) {
} }
substitutions { substitutions {
groups { groups {
shortName old {
} shortName
period { }
startSlot new {
endSlot shortName
startTime }
endTime
wholeDay
} }
startSlot
endSlot
startTime
endTime
wholeDay
teachers { teachers {
shortName shortName
fullName fullName
......
...@@ -125,10 +125,45 @@ class TimetableObjectType(graphene.ObjectType): ...@@ -125,10 +125,45 @@ class TimetableObjectType(graphene.ObjectType):
return f"{root.type.value}-{root.id}" return f"{root.type.value}-{root.id}"
class SubstitutionGroupsType(graphene.ObjectType):
old = graphene.List(GroupType)
new = graphene.List(GroupType)
def resolve_old(root, info):
if not root.cancelled and root.groups.all() and root.amends.groups.all():
return root.amends.groups.all()
else:
return []
def resolve_new(root, info):
if root cancelled:
return root.amends.groups.all()
else:
return root.groups.all() or root.amends.groups.all()
class SubstitutionType(graphene.ObjectType):
"""This type contains the logic also contained in the pdf templates."""
groups = graphene.List(SubstitutionGroupsType)
start_slot = graphene.Int()
end_slot = graphene.Int()
start_time = graphene.Time()
end_time = graphene.Time()
whole_day = graphene.Boolean()
teachers = graphene.List(PersonType)
subject = graphene.String()
rooms = graphene.List(RoomType)
cancelled = graphene.Boolean()
comment = graphene.String()
def resolve_groups(root, info):
return root['REFERENCE_OBJECT']
class SubstitutionsForDateType(graphene.ObjectType): class SubstitutionsForDateType(graphene.ObjectType):
affected_teachers = graphene.List(PersonType) affected_teachers = graphene.List(PersonType)
affected_groups = graphene.List(GroupType) affected_groups = graphene.List(GroupType)
substitutions = graphene.List(LessonEventType) substitutions = graphene.List(SubstitutionType)
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
timetable_teachers = graphene.List(TimetablePersonType) timetable_teachers = graphene.List(TimetablePersonType)
...@@ -137,7 +172,7 @@ class Query(graphene.ObjectType): ...@@ -137,7 +172,7 @@ class Query(graphene.ObjectType):
available_timetables = graphene.List(TimetableObjectType) available_timetables = graphene.List(TimetableObjectType)
substitutions_for_date = graphene.List( substitutions_for_date = graphene.List(
SubstitutionsForDateType, SubstitutionsForDateType,
date=graphene.Date, date=graphene.Date(),
) )
def resolve_timetable_teachers(self, info, **kwargs): def resolve_timetable_teachers(self, info, **kwargs):
...@@ -185,7 +220,7 @@ class Query(graphene.ObjectType): ...@@ -185,7 +220,7 @@ class Query(graphene.ObjectType):
SubstitutionsForDateType( SubstitutionsForDateType(
affected_teachers=affected_teachers, affected_teachers=affected_teachers,
affected_groups=affected_groups, affected_groups=affected_groups,
substitutions=[sub['el']['REFERENCE_OBJECT'] for sub in substitutions] substitutions=[sub['el'] for sub in substitutions]
) )
class Mutation(graphene.ObjectType): class Mutation(graphene.ObjectType):
......
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