Skip to content

Commit 6d34b02

Browse files
Fix co-applicant permission for Partners, Reviewers, and Community Reviewers (#4583)
Fixes #4578 These views are using custom permissions along with submission_view permission, and those custom permissions are causing issues. Now, we have checked if a user with the role of Partner, Reviewer, and Community Reviewer isan applicant or a co-applicant will be redirected to Applicant view.
1 parent 60ce996 commit 6d34b02

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

hypha/apply/funds/views/submission_detail.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ def dispatch(self, request, *args, **kwargs):
115115
submission = self.get_object()
116116
# If the requesting user submitted the application, return the Applicant view.
117117
# Reviewers may sometimes be applicants as well.
118-
if submission.user == request.user:
118+
# or if requesting user is a co-applicant to application, return the Applicant view.
119+
if (
120+
submission.user == request.user
121+
or submission.co_applicants.filter(user=request.user).exists()
122+
):
119123
return ApplicantSubmissionDetailView.as_view()(request, *args, **kwargs)
120124
if submission.status == DRAFT_STATE:
121125
raise Http404
@@ -149,7 +153,11 @@ def dispatch(self, request, *args, **kwargs):
149153
)
150154
# If the requesting user submitted the application, return the Applicant view.
151155
# Partners may sometimes be applicants as well.
152-
if submission.user == request.user:
156+
# or if requesting user is a co-applicant to application, return the Applicant view.
157+
if (
158+
submission.user == request.user
159+
or submission.co_applicants.filter(user=request.user).exists()
160+
):
153161
return ApplicantSubmissionDetailView.as_view()(request, *args, **kwargs)
154162
# Only allow partners in the submission they are added as partners
155163
partner_has_access = submission.partners.filter(pk=request.user.pk).exists()
@@ -171,7 +179,11 @@ def dispatch(self, request, *args, **kwargs):
171179
)
172180
# If the requesting user submitted the application, return the Applicant view.
173181
# Reviewers may sometimes be applicants as well.
174-
if submission.user == request.user:
182+
# or if requesting user is a co-applicant to application, return the Applicant view.
183+
if (
184+
submission.user == request.user
185+
or submission.co_applicants.filter(user=request.user).exists()
186+
):
175187
return ApplicantSubmissionDetailView.as_view()(request, *args, **kwargs)
176188
# Only allow community reviewers in submission with a community review state.
177189
if not submission.community_review:

0 commit comments

Comments
 (0)