Skip to content

Commit c670e82

Browse files
committed
Clearer co-applicant permission handeling.
1 parent 1fd491b commit c670e82

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

hypha/apply/funds/permissions.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ def can_edit_submission(user, submission):
3838
if submission.phase.permissions.can_edit(user):
3939
co_applicant = submission.co_applicants.filter(user=user).first()
4040
if co_applicant:
41-
if co_applicant.role not in [CoApplicantRole.VIEW, CoApplicantRole.COMMENT]:
42-
return (
43-
True,
44-
"Co-applicant with read/view only or comment access can't edit submission",
45-
)
46-
return False, ""
41+
if co_applicant.role == CoApplicantRole.EDIT:
42+
return True, "Co-applicant with edit role can edit submission"
43+
return False, "Co-applicant does not have edit role"
4744
return True, "User can edit in current phase"
4845
return False, ""
4946

@@ -147,6 +144,7 @@ def get_archive_alter_groups() -> list:
147144
def can_alter_archived_submissions(user, submission=None) -> (bool, str):
148145
"""
149146
Return a boolean based on if a user can alter archived submissions
147+
(submission is accepted for compatibility with permissions_map but not used)
150148
"""
151149
archive_access_groups = get_archive_alter_groups()
152150

@@ -242,7 +240,7 @@ def can_invite_co_applicants(user, submission):
242240
if project.status == COMPLETE:
243241
return False, "Co-applicants can't be invited to completed projects"
244242
if (
245-
submission.co_applicant_invites.all().count()
243+
submission.co_applicant_invites.count()
246244
>= settings.SUBMISSIONS_COAPPLICANT_INVITES_LIMIT
247245
):
248246
return False, "Limit reached for this submission"

0 commit comments

Comments
 (0)