|
9 | 9 | from tempfile import mkstemp |
10 | 10 |
|
11 | 11 | from django.http import HttpRequest, Http404 |
12 | | -from django.db.models import Max, Q, Prefetch |
| 12 | +from django.db.models import F, Max, Q, Prefetch |
13 | 13 | from django.conf import settings |
14 | 14 | from django.core.cache import cache |
15 | 15 | from django.urls import reverse |
@@ -164,13 +164,17 @@ def get_schedule_by_name(meeting, owner, name): |
164 | 164 | return meeting.schedule_set.filter(name = name).first() |
165 | 165 |
|
166 | 166 | def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefetches=()): |
167 | | - assignments_queryset = assignments_queryset.select_related( |
168 | | - "timeslot", "timeslot__location", "timeslot__type", |
169 | | - ).prefetch_related( |
| 167 | + assignments_queryset = assignments_queryset.prefetch_related( |
| 168 | + 'timeslot', 'timeslot__type', 'timeslot__meeting', |
| 169 | + 'timeslot__location', 'timeslot__location__floorplan', 'timeslot__location__urlresource_set', |
170 | 170 | Prefetch( |
171 | 171 | "session", |
172 | 172 | queryset=add_event_info_to_session_qs(Session.objects.all().prefetch_related( |
173 | 173 | 'group', 'group__charter', 'group__charter__group', |
| 174 | + Prefetch('materials', |
| 175 | + queryset=Document.objects.exclude(states__type=F("type"), states__slug='deleted').order_by('sessionpresentation__order').prefetch_related('states'), |
| 176 | + to_attr='prefetched_active_materials' |
| 177 | + ) |
174 | 178 | )) |
175 | 179 | ), |
176 | 180 | *extra_prefetches |
@@ -212,6 +216,12 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefe |
212 | 216 | if a.session and a.session.historic_group and a.session.historic_group.parent_id: |
213 | 217 | a.session.historic_group.historic_parent = parent_replacements.get(a.session.historic_group.parent_id) |
214 | 218 |
|
| 219 | + for d in a.session.prefetched_active_materials: |
| 220 | + # make sure these are precomputed with the meeting instead |
| 221 | + # of having to look it up |
| 222 | + d.get_href(meeting=meeting) |
| 223 | + d.get_versionless_href(meeting=meeting) |
| 224 | + |
215 | 225 | return assignments |
216 | 226 |
|
217 | 227 | def read_session_file(type, num, doc): |
|
0 commit comments