diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index 0593f09feff319e9e50962142d13c34722a7943b..ae4e7521e92dfc6caf618a9c87320bf692315740 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 5b45873321a260bdf876fb8a0d04ea14c9846bb8..3a50b901dfa80587cff725343b07ac80fbb9699d 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):