diff --git a/fiesta/apps/buddy_system/views/matches.py b/fiesta/apps/buddy_system/views/matches.py index fc6aae62..c07573df 100644 --- a/fiesta/apps/buddy_system/views/matches.py +++ b/fiesta/apps/buddy_system/views/matches.py @@ -18,7 +18,9 @@ class MyBuddies(EnsureLocalUserViewMixin, ListView): def get_queryset(self): return ( - self.request.user.buddy_system_request_matches.prefetch_related("request__issuer__emailaddress_set") + self.request.user.buddy_system_request_matches.prefetch_related( + "request__issuer__emailaddress_set", + ) .select_related( "request__issuer__profile__user", "request__issuer__profile__university", diff --git a/fiesta/apps/buddy_system/views/matching.py b/fiesta/apps/buddy_system/views/matching.py index c122e685..ca3885f2 100644 --- a/fiesta/apps/buddy_system/views/matching.py +++ b/fiesta/apps/buddy_system/views/matching.py @@ -47,7 +47,12 @@ def get_permission_denied_message(self): def get_queryset(self): return self.configuration.matching_policy_instance.limit_requests( - qs=BuddyRequest.objects.get_queryset(), + qs=BuddyRequest.objects.get_queryset().select_related( + # select all potentially necessary fields in the template afterward + "issuer__profile__user", + "issuer__profile__university", + "issuer__profile__faculty", + ), membership=self.request.membership, ) diff --git a/fiesta/apps/pickup_system/views/matches.py b/fiesta/apps/pickup_system/views/matches.py index 9958478c..7bc319c3 100644 --- a/fiesta/apps/pickup_system/views/matches.py +++ b/fiesta/apps/pickup_system/views/matches.py @@ -18,8 +18,12 @@ class MyPickups(EnsureLocalUserViewMixin, ListView): def get_queryset(self): return ( - self.request.user.pickup_system_request_matches.prefetch_related("request__issuer__profile") - .select_related("request", "matcher") + self.request.user.pickup_system_request_matches.prefetch_related("request__issuer__emailaddress_set") + .select_related( + "request__issuer__profile__user", + "request__issuer__profile__university", + "request__issuer__profile__faculty", + ) .filter( request__state=BaseRequestProtocol.State.MATCHED, ) diff --git a/fiesta/apps/pickup_system/views/matching.py b/fiesta/apps/pickup_system/views/matching.py index c6a8c96d..074ab096 100644 --- a/fiesta/apps/pickup_system/views/matching.py +++ b/fiesta/apps/pickup_system/views/matching.py @@ -32,7 +32,9 @@ class MatchingRequestsView( def get_queryset(self): return self.request.in_space_of_section.pickup_system_requests.select_related( - "issuer__profile__user", "issuer__profile__university", "issuer__profile__faculty" + "issuer__profile__user", + "issuer__profile__university", + "issuer__profile__faculty", ).filter( state=PickupRequest.State.CREATED, )