Skip to content

Commit

Permalink
Distinguish withdrawal permissions
Browse files Browse the repository at this point in the history
Add distinct withdrawal permissions within stages of workflows. By
default, let the applicant withdraw at any stage. On the submission
page, display the Withdraw button assuming the setting
`ENABLE_SUBMISSION_WITHDRAWAL` is true and the withdrawal permissions
are met.

Issue #3296
  • Loading branch information
bickelj authored and frjo committed Nov 27, 2024
1 parent cccc5e2 commit 90849fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
{% trans "Delete" %}
</a>
{% endif %}
{% if ENABLE_SUBMISSION_WITHDRAWAL and request.user.is_applicant %}
{% if request.user|has_withdraw_perm:object %}
<a
class="link link--withdraw-submission is-active"
href="{% url 'funds:submissions:withdraw' object.id %}">
Expand Down
7 changes: 7 additions & 0 deletions hypha/apply/funds/templatetags/workflow_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@ def display_submission_author(context: dict, revision_author: bool = False) -> s
return settings.ORG_LONG_NAME # Likely an edge case but covering bases

return str(author)


@register.filter
def has_withdraw_perm(user, submission):
if settings.ENABLE_SUBMISSION_WITHDRAWAL:
return check_permission(user, "withdraw", submission)
return False
6 changes: 5 additions & 1 deletion hypha/apply/funds/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ def can_review(self, user):
def can_view(self, user):
return self.can_do(user, "view")

def can_withdraw(self, user):
return self.can_do(user, "withdraw")


staff_can = lambda user: user.is_apply_staff # NOQA

Expand All @@ -193,7 +196,7 @@ def can_view(self, user):
community_can = lambda user: user.is_community_reviewer # NOQA


def make_permissions(edit=None, review=None, view=None):
def make_permissions(edit=None, review=None, view=None, withdraw=None):
return {
"edit": edit or [],
"review": review or [],
Expand All @@ -204,6 +207,7 @@ def make_permissions(edit=None, review=None, view=None):
reviewer_can,
partner_can,
],
"withdraw": withdraw or [applicant_can],
}


Expand Down

0 comments on commit 90849fb

Please sign in to comment.