Skip to content
Snippets Groups Projects
Verified Commit 821a2e12 authored by mirabilos's avatar mirabilos Committed by mirabilos
Browse files

Annotate lesson_periods with whether they have documentation.

Advances #9.

An alternative way of writing…

	foo.filter(a, ~Q(b))

… is…

	foo.filter(a).exclude(b)

… if this way is disturbing to the reader.
parent 7bb3c792
No related branches found
No related tags found
No related merge requests found
......@@ -102,7 +102,12 @@ def group_week(request: HttpRequest, week: Optional[int] = None) -> HttpResponse
raise Http404(_('You must select a group to see the week summary.'))
# Get all lesson periods for the selected group
lesson_periods = LessonPeriod.objects.filter(
lesson_periods = LessonPeriod.objects.annotate(
has_documentation=Exists(LessonDocumentation.objects.filter(
lesson_period=OuterRef('pk'),
~Q(topic__exact='')
))
).filter(
lesson__date_start__lte=week_start,
lesson__date_end__gte=week_end
).select_related(
......
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