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

Use update version of get_objects

parent 9f67b1e1
No related branches found
No related tags found
1 merge request!381Optimize get objects
Pipeline #193524 passed
...@@ -406,13 +406,13 @@ class LessonEvent(CalendarEvent): ...@@ -406,13 +406,13 @@ class LessonEvent(CalendarEvent):
params: dict[str, any] | None = None, params: dict[str, any] | None = None,
no_effect: bool = False, no_effect: bool = False,
**kwargs, **kwargs,
) -> Iterable: ) -> QuerySet:
"""Return all objects that should be included in the calendar.""" """Return all objects that should be included in the calendar."""
if no_effect: if no_effect:
return super().get_objects(request, params, **kwargs) return super().get_objects(request, params, **kwargs)
if request and not has_person(request.user): if request and not has_person(request.user):
return [] return cls.objects.none()
q = Q() q = Q()
...@@ -458,13 +458,14 @@ class LessonEvent(CalendarEvent): ...@@ -458,13 +458,14 @@ class LessonEvent(CalendarEvent):
elif request: elif request:
q = q & LessonEventQuerySet.for_person_q(request.user.person) q = q & LessonEventQuerySet.for_person_q(request.user.person)
objs = ( objs = super().get_objects(
super() request,
.get_objects(request, params, additional_filter=q, **kwargs) params,
.not_instance_of(SupervisionEvent) start_qs=cls.objects.not_instance_of(SupervisionEvent),
.filter(q) additional_filter=q,
.select_related("subject", "course") select_related=["subject", "course"],
.prefetch_related("groups", "teachers", "rooms", "groups__members") prefetch_related=["groups", "teachers", "rooms", "groups__members"],
**kwargs,
) )
return objs return objs
......
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