From 1c012de5188b675b3c6e6886a0e6c5968f6df160 Mon Sep 17 00:00:00 2001 From: Frank Duncan Date: Thu, 23 Mar 2023 05:20:20 -0500 Subject: [PATCH] Add ENABLE_SUBMISSION_WITHDRAWAL to allow enabling withdrawals This only affects about enabling them, not whether they are in the system. That means that if the configuration is changed over the lifetime of a system, things that were withdrawn when it was enabled retain that status. Issue #3296 --- docs/setup/administrators/configuration.md | 6 +++++- hypha/apply/funds/views.py | 3 +++ hypha/apply/funds/workflow.py | 2 +- hypha/core/context_processors.py | 1 + hypha/settings/base.py | 3 +++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/setup/administrators/configuration.md b/docs/setup/administrators/configuration.md index 111a1f7fca..f12add250e 100644 --- a/docs/setup/administrators/configuration.md +++ b/docs/setup/administrators/configuration.md @@ -112,7 +112,11 @@ If applicants should be forced to preview their application before submitting ---- -Set the allowed file extension for all uploads fields. +### Allow Withdrawing of Submissions + + ENABLE_SUBMISSION_WITHDRAWAL = env.bool('ENABLE_SUBMISSION_WITHDRAWAL', False) + +### Set the allowed file extension for all uploads fields. FILE_ALLOWED_EXTENSIONS = ['doc', 'docx', 'odp', 'ods', 'odt', 'pdf', 'ppt', 'pptx', 'rtf', 'txt', 'xls', 'xlsx'] FILE_ACCEPT_ATTR_VALUE = ', '.join(['.' + ext for ext in FILE_ALLOWED_EXTENSIONS]) diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 20d6cb78b2..48e12991d3 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1591,6 +1591,9 @@ def post(self, request, *args, **kwargs): return self.withdraw(request, *args, **kwargs) def withdraw(self, request, *args, **kwargs): + if not settings.ENABLE_SUBMISSION_WITHDRAWAL: + raise PermissionDenied + obj = self.get_object() if not obj.phase.permissions.can_edit(request.user): diff --git a/hypha/apply/funds/workflow.py b/hypha/apply/funds/workflow.py index ef3efadf95..f67d0409fe 100644 --- a/hypha/apply/funds/workflow.py +++ b/hypha/apply/funds/workflow.py @@ -407,7 +407,7 @@ def make_permissions(edit=None, review=None, view=None): "display": _("Need screening"), "public": _("Application Received"), "stage": RequestExt, - "permissions": default_permissions, + "permissions": applicant_edit_permissions, }, "ext_more_info": { "transitions": { diff --git a/hypha/core/context_processors.py b/hypha/core/context_processors.py index 21c4785d86..235de21b54 100644 --- a/hypha/core/context_processors.py +++ b/hypha/core/context_processors.py @@ -20,4 +20,5 @@ def global_vars(request): "SENTRY_DENY_URLS": settings.SENTRY_DENY_URLS, "SENTRY_DEBUG": settings.SENTRY_DEBUG, "SENTRY_PUBLIC_KEY": settings.SENTRY_PUBLIC_KEY, + "ENABLE_SUBMISSION_WITHDRAWAL": settings.ENABLE_SUBMISSION_WITHDRAWAL, } diff --git a/hypha/settings/base.py b/hypha/settings/base.py index 60bcb0a9bf..b80c90f2fc 100644 --- a/hypha/settings/base.py +++ b/hypha/settings/base.py @@ -158,6 +158,9 @@ # Require an applicant to view their rendered application before submitting SUBMISSION_PREVIEW_REQUIRED = env.bool("SUBMISSION_PREVIEW_REQUIRED", True) +# Allow Withdrawing of Submissions +ENABLE_SUBMISSION_WITHDRAWAL = env.bool('ENABLE_SUBMISSION_WITHDRAWAL', False) + # Project settings. # SECRET_KEY is required