From e4cad102af0c5a4f1529f6d4840a9e09e91083cf 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 59aa689c68..7a3e7cf978 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 94c8f1c276..3cee68a71a 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1797,6 +1797,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 8be2f11fa1..6794642ebb 100644 --- a/hypha/apply/funds/workflow.py +++ b/hypha/apply/funds/workflow.py @@ -547,7 +547,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 d1efdf6b6b..e79c2b6718 100644 --- a/hypha/core/context_processors.py +++ b/hypha/core/context_processors.py @@ -22,4 +22,5 @@ def global_vars(request): "SENTRY_DEBUG": settings.SENTRY_DEBUG, "SENTRY_PUBLIC_KEY": settings.SENTRY_PUBLIC_KEY, "SUBMISSIONS_TABLE_EXCLUDED_FIELDS": settings.SUBMISSIONS_TABLE_EXCLUDED_FIELDS, + "ENABLE_SUBMISSION_WITHDRAWAL": settings.ENABLE_SUBMISSION_WITHDRAWAL, } diff --git a/hypha/settings/base.py b/hypha/settings/base.py index 37efac3224..709a505370 100644 --- a/hypha/settings/base.py +++ b/hypha/settings/base.py @@ -162,6 +162,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