Skip to content
Snippets Groups Projects
Verified Commit ca78f7cd authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Fix getters for substitutions table schema to work with events that are not amending other events

parent 650cc709
No related branches found
No related tags found
1 merge request!394Show events with current changes in substitutions table
......@@ -153,11 +153,13 @@ class SubstitutionType(graphene.ObjectType):
def resolve_old_groups(root, info):
le = root["REFERENCE_OBJECT"]
return le.amends.groups.all() or le.groups.all()
if le.amends and le.amends.groups.all():
return le.amends.groups.all()
return le.groups.all()
def resolve_new_groups(root, info):
le = root["REFERENCE_OBJECT"]
if le.groups.all() and le.amends.groups.all():
if le.groups.all() and le.amends and le.amends.groups.all():
return le.groups.all()
else:
return []
......@@ -176,11 +178,13 @@ class SubstitutionType(graphene.ObjectType):
def resolve_old_teachers(root, info):
le = root["REFERENCE_OBJECT"]
return le.amends.teachers.all() or le.teachers.all()
if le.amends and le.amends.teachers.all():
return le.amends.teachers.all()
return le.teachers.all()
def resolve_new_teachers(root, info):
le = root["REFERENCE_OBJECT"]
if le.teachers.all() and le.amends.teachers.all():
if le.teachers.all() and le.amends and le.amends.teachers.all():
return le.teachers.all()
else:
return []
......@@ -189,30 +193,32 @@ class SubstitutionType(graphene.ObjectType):
le = root["REFERENCE_OBJECT"]
if le.name == "supervision":
return "SUPERVISION"
elif not le.amends.subject and not le.subject:
return le.amends.title
elif not (le.amends and le.amends.subject) and not le.subject:
if le.amends:
return le.amends.title
return le.title
else:
subject = le.amends.subject or le.subject
subject = le.amends.subject if le.amends and le.amends.subject else le.subject
return subject.short_name or subject.name
def resolve_new_subject(root, info):
le = root["REFERENCE_OBJECT"]
if le.name == "supervision":
return None
elif not le.amends.subject and not le.subject:
return le.title
elif le.subject and le.amends.subject:
elif le.subject and le.amends and le.amends.subject:
return le.subject.short_name or le.subject.name
else:
return None
def resolve_old_rooms(root, info):
le = root["REFERENCE_OBJECT"]
return le.amends.rooms.all() or le.rooms.all()
if le.amends and le.amends.rooms.all():
return le.amends.rooms.all()
return le.rooms.all()
def resolve_new_rooms(root, info):
le = root["REFERENCE_OBJECT"]
if le.rooms.all() and le.amends.rooms.all():
if le.rooms.all() and le.amends and le.amends.rooms.all():
return le.rooms.all()
else:
return []
......@@ -221,7 +227,7 @@ class SubstitutionType(graphene.ObjectType):
return root["REFERENCE_OBJECT"].cancelled
def resolve_notes(root, info):
return root["REFERENCE_OBJECT"].title or root["REFERENCE_OBJECT"].comment
return root["REFERENCE_OBJECT"].comment
class SubstitutionsForDateType(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