Skip to content

Commit f4ae001

Browse files
committed
Distinguish withdrawal permissions
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
1 parent 8d03e12 commit f4ae001

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

hypha/apply/funds/templates/funds/applicationsubmission_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
111111
{% trans "Delete" %}
112112
</a>
113113
{% endif %}
114-
{% if ENABLE_SUBMISSION_WITHDRAWAL and request.user.is_applicant %}
114+
{% if request.user|has_withdraw_perm:object %}
115115
<a
116116
class="link link--withdraw-submission is-active"
117117
href="{% url 'funds:submissions:withdraw' object.id %}">

hypha/apply/funds/templatetags/workflow_tags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import template
2+
from django.conf import settings
23

34
register = template.Library()
45

@@ -18,3 +19,10 @@ def has_edit_perm(user, submission):
1819
@register.filter
1920
def has_review_perm(user, submission):
2021
return check_permission(user, "review", submission)
22+
23+
24+
@register.filter
25+
def has_withdraw_perm(user, submission):
26+
if settings.ENABLE_SUBMISSION_WITHDRAWAL:
27+
return check_permission(user, "withdraw", submission)
28+
return False

hypha/apply/funds/workflow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def can_review(self, user):
178178
def can_view(self, user):
179179
return self.can_do(user, "view")
180180

181+
def can_withdraw(self, user):
182+
return self.can_do(user, "withdraw")
183+
181184

182185
staff_can = lambda user: user.is_apply_staff # NOQA
183186

@@ -190,7 +193,7 @@ def can_view(self, user):
190193
community_can = lambda user: user.is_community_reviewer # NOQA
191194

192195

193-
def make_permissions(edit=None, review=None, view=None):
196+
def make_permissions(edit=None, review=None, view=None, withdraw=None):
194197
return {
195198
"edit": edit or [],
196199
"review": review or [],
@@ -201,6 +204,7 @@ def make_permissions(edit=None, review=None, view=None):
201204
reviewer_can,
202205
partner_can,
203206
],
207+
"withdraw": withdraw or [applicant_can],
204208
}
205209

206210

0 commit comments

Comments
 (0)