From 5baf01a0d46dc6a5edb9dd59ee822d450e14d2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Kol=C3=A1=C5=99?= Date: Sat, 26 Aug 2023 18:31:46 +0200 Subject: [PATCH] fix(buddy-system): allow displaying picture profile of buddy request matcher --- fiesta/apps/buddy_system/views/matching.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fiesta/apps/buddy_system/views/matching.py b/fiesta/apps/buddy_system/views/matching.py index 5a205bf9..4785d3b4 100644 --- a/fiesta/apps/buddy_system/views/matching.py +++ b/fiesta/apps/buddy_system/views/matching.py @@ -15,6 +15,7 @@ from apps.plugins.views import PluginConfigurationViewMixin from apps.sections.views.mixins.membership import EnsureLocalUserViewMixin from apps.sections.views.mixins.section_space import EnsureInSectionSpaceViewMixin +from apps.utils.models.query import Q class MatchingRequestsView( @@ -71,9 +72,13 @@ class ProfilePictureServeView( ): def has_permission(self, request: HttpRequest, name: str) -> bool: # is the file in requests, for whose is the related section responsible? - related_requests = request.membership.section.buddy_system_requests.filter(issuer__profile__picture=name) + related_requests = request.membership.section.buddy_system_requests.filter( + Q(issuer__profile__picture=name) | Q(matched_by__profile__picture=name) + ) # does have the section enabled picture displaying? return (related_requests.exists() and self.configuration and self.configuration.display_issuer_picture) or ( - related_requests.filter(matched_by=request.user, state=BuddyRequest.State.MATCHED).exists() + related_requests.filter( + Q(matched_by=request.user) | Q(issuer=request.user), state=BuddyRequest.State.MATCHED + ).exists() )