diff --git a/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html b/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html index 730d4d0db4..fbc0488582 100644 --- a/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html +++ b/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html @@ -1,4 +1,4 @@ -{% load i18n dashboard_statusbar_tags statusbar_tags workflow_tags heroicons %} +{% load i18n dashboard_statusbar_tags statusbar_tags workflow_tags heroicons submission_tags %} {% for submission in page.object_list %}
{% status_bar submission.workflow submission.phase request.user css_class="status-bar--small" %} diff --git a/hypha/apply/funds/permissions.py b/hypha/apply/funds/permissions.py index 02fcd1dacb..90bd8d8318 100644 --- a/hypha/apply/funds/permissions.py +++ b/hypha/apply/funds/permissions.py @@ -1,6 +1,8 @@ from django.conf import settings from django.core.exceptions import PermissionDenied +from hypha.apply.funds.models.submissions import DRAFT_STATE + from ..users.groups import STAFF_GROUP_NAME, SUPERADMIN, TEAMADMIN_GROUP_NAME @@ -24,6 +26,14 @@ def can_edit_submission(user, submission): return True, "" +def can_delete_submission(user, submission): + if user.has_perm("funds.delete_applicationsubmission"): + return True, "User can delete submission" + elif user == submission.user and submission.status == DRAFT_STATE: + return True, "Applicant can delete draft submissions" + return False, "Forbidden Error" + + def can_bulk_delete_submissions(user) -> bool: if user.is_apply_staff: return True @@ -164,6 +174,7 @@ def can_view_submission_screening(user, submission): permissions_map = { "submission_view": is_user_has_access_to_view_submission, "submission_edit": can_edit_submission, + "submission_delete": can_delete_submission, "can_view_submission_screening": can_view_submission_screening, "archive_alter": can_alter_archived_submissions, } diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html b/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html index bd4ee4fb9a..5a015982f2 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html @@ -13,11 +13,18 @@- Are you sure you want to delete submission? All of your data - will be permanently removed from our servers forever. This - includes reviews, determinations and comments. This action cannot be undone. -
+ {% if request.user.is_applicant %} ++ Are you sure you want to delete draft submission? All of your data for this submission + will be permanently removed from our servers forever. This action cannot be undone. +
+ {% else %} ++ Are you sure you want to delete submission? All of your data + will be permanently removed from our servers forever. This + includes reviews, determinations and comments. This action cannot be undone. +
+ {% endif %}