Skip to content
Snippets Groups Projects
Commit 9e492da7 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add get_objects method for Supervisions

parent 3f75b026
No related branches found
No related tags found
1 merge request!301New data model based on calendar events
Pipeline #143261 failed
......@@ -1615,3 +1615,20 @@ class SupervisionEvent(LessonEvent):
return render_to_string(
"chronos/supervision_event_description.txt", {"event": reference_object}
)
@classmethod
def get_objects(cls, request, params=None) -> Iterable:
"""Return all objects that should be included in the calendar."""
objs = super().get_objects(request, params)
if params:
obj_id = int(params.get("id", 0))
type = params.get("type", None)
if type and obj_id:
if type == "TEACHER":
return objs.for_teacher(obj_id)
elif type == "GROUP":
return objs.for_group(obj_id)
elif type == "ROOM":
return objs.for_room(obj_id)
return objs.for_person(request.user.person)
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