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 committed Jul 25, 2024
1 parent 8d03e12 commit f4ae001
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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
8 changes: 8 additions & 0 deletions hypha/apply/funds/templatetags/workflow_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django import template
from django.conf import settings

register = template.Library()

Expand All @@ -18,3 +19,10 @@ def has_edit_perm(user, submission):
@register.filter
def has_review_perm(user, submission):
return check_permission(user, "review", submission)


@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 @@ -178,6 +178,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 @@ -190,7 +193,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 @@ -201,6 +204,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 f4ae001

Please sign in to comment.