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 %}
@@ -28,6 +28,13 @@

{% endif %} {% endif %} + {% user_can_delete_submission submission request.user as can_delete_submission %} + {% if can_delete_submission %} + + {% heroicon_micro "trash" class="inline me-1 mt-1 fill-red-600" aria_hidden=true %} + {% trans "Delete" %} + + {% endif %}

{% 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 %}
diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html index d456e94c36..7f7a134f83 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html @@ -1,5 +1,5 @@ {% extends "base-apply.html" %} -{% load i18n static workflow_tags wagtailcore_tags statusbar_tags archive_tags %} +{% load i18n static workflow_tags wagtailcore_tags statusbar_tags archive_tags submission_tags %} {% load heroicons %} {% block title %}#{{ object.public_id|default_if_none:object.id}}: {{ object.title }}{% endblock %} @@ -119,7 +119,8 @@
{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
- {% if perms.funds.delete_applicationsubmission %} + {% user_can_delete_submission object request.user as can_delete_submission %} + {% if can_delete_submission %}