From 43956df389810e027cb55c891ee69e87acbea805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Kol=C3=A1=C5=99?= Date: Sun, 19 Nov 2023 18:42:36 +0100 Subject: [PATCH] fix(requests): respect request state on my-matches pages --- fiesta/apps/buddy_system/views/matches.py | 11 ++++++++--- fiesta/apps/pickup_system/views/matches.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fiesta/apps/buddy_system/views/matches.py b/fiesta/apps/buddy_system/views/matches.py index 6c18f202..98206e0a 100644 --- a/fiesta/apps/buddy_system/views/matches.py +++ b/fiesta/apps/buddy_system/views/matches.py @@ -3,6 +3,7 @@ from django.utils.translation import gettext_lazy as _ from django.views.generic import ListView +from apps.fiestarequests.models.request import BaseRequestProtocol from apps.plugins.middleware.plugin import HttpRequest from apps.sections.views.mixins.membership import EnsureLocalUserViewMixin from apps.utils.breadcrumbs import with_breadcrumb, with_plugin_home_breadcrumb @@ -16,6 +17,10 @@ class MyBuddies(EnsureLocalUserViewMixin, ListView): template_name = "buddy_system/my_buddies.html" def get_queryset(self): - return self.request.user.buddy_system_request_matches.prefetch_related( - "request__issuer__profile" - ).select_related("request", "matcher") + return ( + self.request.user.buddy_system_request_matches.prefetch_related("request__issuer__profile") + .select_related("request", "matcher") + .filter( + request__state=BaseRequestProtocol.State.MATCHED, + ) + ) diff --git a/fiesta/apps/pickup_system/views/matches.py b/fiesta/apps/pickup_system/views/matches.py index 5f2d3ad8..9958478c 100644 --- a/fiesta/apps/pickup_system/views/matches.py +++ b/fiesta/apps/pickup_system/views/matches.py @@ -3,6 +3,7 @@ from django.utils.translation import gettext_lazy as _ from django.views.generic import ListView +from apps.fiestarequests.models.request import BaseRequestProtocol from apps.plugins.middleware.plugin import HttpRequest from apps.sections.views.mixins.membership import EnsureLocalUserViewMixin from apps.utils.breadcrumbs import with_breadcrumb, with_plugin_home_breadcrumb @@ -16,6 +17,10 @@ class MyPickups(EnsureLocalUserViewMixin, ListView): template_name = "pickup_system/my_pickups.html" def get_queryset(self): - return self.request.user.pickup_system_request_matches.prefetch_related( - "request__issuer__profile" - ).select_related("request", "matcher") + return ( + self.request.user.pickup_system_request_matches.prefetch_related("request__issuer__profile") + .select_related("request", "matcher") + .filter( + request__state=BaseRequestProtocol.State.MATCHED, + ) + )