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

Fix order of queries in week view

Week has to be annotated before querying teachers
parent 442e28eb
No related branches found
No related tags found
1 merge request!49Resolve "Add rules and permissions"
Pipeline #2756 passed
...@@ -121,9 +121,14 @@ def week_view( ...@@ -121,9 +121,14 @@ def week_view(
) -> HttpResponse: ) -> HttpResponse:
context = {} context = {}
if year and week:
wanted_week = CalendarWeek(year=year, week=week)
else:
wanted_week = CalendarWeek()
instance = get_instance_by_pk(request, year, week, type_, id_) instance = get_instance_by_pk(request, year, week, type_, id_)
lesson_periods = LessonPeriod.objects lesson_periods = LessonPeriod.objects.in_week(wanted_week)
if type_ and id_: if type_ and id_:
if isinstance(instance, HttpResponseNotFound): if isinstance(instance, HttpResponseNotFound):
...@@ -141,19 +146,13 @@ def week_view( ...@@ -141,19 +146,13 @@ def week_view(
else: else:
lesson_periods = None lesson_periods = None
if year and week:
wanted_week = CalendarWeek(year=year, week=week)
else:
wanted_week = CalendarWeek()
lesson_periods = lesson_periods.annotate( lesson_periods = lesson_periods.annotate(
has_documentation=Exists( has_documentation=Exists(
LessonDocumentation.objects.filter( LessonDocumentation.objects.filter(
~Q(topic__exact=""), lesson_period=OuterRef("pk"), week=wanted_week.week ~Q(topic__exact=""), lesson_period=OuterRef("pk"), week=wanted_week.week
) )
) )
).in_week(wanted_week) )
# Add a form to filter the view # Add a form to filter the view
if type_: if type_:
......
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