From 1bf4c2c36d64cc8370dd70cafd10546108dcf05a Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Mon, 2 Aug 2021 19:08:41 +0530 Subject: [PATCH] Fix Review visibility and use exclude for existing data --- hypha/apply/activity/messaging.py | 9 +++++++++ hypha/apply/activity/models.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index 0593f09fe..ae4e7521e 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -273,6 +273,15 @@ class ActivityAdapter(AdapterBase): if is_transition(message_type) and not source.phase.permissions.can_view(source.user): # User's shouldn't see status activity changes for stages that aren't visible to the them return {'visibility': TEAM} + + # to fix visibility issue of review for applicant + if message_type in [ + MESSAGES.NEW_REVIEW, + MESSAGES.EDIT_REVIEW, + MESSAGES.DELETE_REVIEW, + ] and kwargs.get('related'): + return {"visibility": kwargs.get('related').visibility} + return {} def reviewers_updated(self, added=list(), removed=list(), **kwargs): diff --git a/hypha/apply/activity/models.py b/hypha/apply/activity/models.py index 5b4587332..3a50b901d 100644 --- a/hypha/apply/activity/models.py +++ b/hypha/apply/activity/models.py @@ -41,6 +41,13 @@ VISIBILITY = { class BaseActivityQuerySet(models.QuerySet): def visible_to(self, user): + # to hide reviews from applicant of existing data + from .messaging import ActivityAdapter + messages = ActivityAdapter.messages + if user.is_applicant: + return self.exclude( + message=messages.get(MESSAGES.NEW_REVIEW) + ).filter(visibility__in=self.model.visibility_for(user)) return self.filter(visibility__in=self.model.visibility_for(user)) def newer(self, activity): -- GitLab