From 8a0430534a60f51545ed110f4c5cd973e2a7fd47 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Fri, 1 May 2026 20:55:03 +0200 Subject: [PATCH 1/4] Proper confirm dialogs for batch archive and batch delete of submissions. --- .../funds/templates/submissions/all.html | 10 ++-- .../submissions/bulk_archive_confirm.html | 39 ++++++++++++++++ .../submissions/bulk_delete_confirm.html | 16 +++++++ hypha/apply/funds/urls.py | 12 +++++ hypha/apply/funds/views/all.py | 46 +++++++++++++++---- hypha/templates/cotton/modal/confirm.html | 2 +- 6 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 hypha/apply/funds/templates/submissions/bulk_archive_confirm.html create mode 100644 hypha/apply/funds/templates/submissions/bulk_delete_confirm.html diff --git a/hypha/apply/funds/templates/submissions/all.html b/hypha/apply/funds/templates/submissions/all.html index 5f0e5a57bc..6566f469cb 100644 --- a/hypha/apply/funds/templates/submissions/all.html +++ b/hypha/apply/funds/templates/submissions/all.html @@ -480,9 +480,10 @@ {% if can_bulk_archive %} + + + diff --git a/hypha/apply/funds/templates/submissions/bulk_delete_confirm.html b/hypha/apply/funds/templates/submissions/bulk_delete_confirm.html new file mode 100644 index 0000000000..41bf35700e --- /dev/null +++ b/hypha/apply/funds/templates/submissions/bulk_delete_confirm.html @@ -0,0 +1,16 @@ +{% load i18n %} + + +

+ {% blocktranslate trimmed with count=submission_ids|length %} + Are you sure you want to permanently delete {{ count }} submission(s)? + All data will be permanently removed. This action cannot be undone. + {% endblocktranslate %} +

+ {% for id in submission_ids %} + + {% endfor %} +
diff --git a/hypha/apply/funds/urls.py b/hypha/apply/funds/urls.py index 300cdcb87a..5fae67faa6 100644 --- a/hypha/apply/funds/urls.py +++ b/hypha/apply/funds/urls.py @@ -12,7 +12,9 @@ from .views.all import ( bulk_anonymize_submissions, bulk_archive_submissions, + bulk_archive_submissions_confirm, bulk_delete_submissions, + bulk_delete_submissions_confirm, bulk_update_submissions_status, submissions_all, ) @@ -97,7 +99,17 @@ ), path("success//", submission_success, name="success"), path("all/", submissions_all, name="list"), + path( + "all/bulk_archive_confirm/", + bulk_archive_submissions_confirm, + name="bulk-archive-confirm", + ), path("all/bulk_archive/", bulk_archive_submissions, name="bulk-archive"), + path( + "all/bulk_delete_confirm/", + bulk_delete_submissions_confirm, + name="bulk-delete-confirm", + ), path("all/bulk_delete/", bulk_delete_submissions, name="bulk-delete"), path("all/bulk_anonymize/", bulk_anonymize_submissions, name="bulk-anonymize"), path( diff --git a/hypha/apply/funds/views/all.py b/hypha/apply/funds/views/all.py index 90e4c37037..49f6981bf4 100644 --- a/hypha/apply/funds/views/all.py +++ b/hypha/apply/funds/views/all.py @@ -9,13 +9,9 @@ from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator from django.db import models -from django.http import ( - HttpRequest, - HttpResponse, - HttpResponseForbidden, -) -from django.shortcuts import render -from django.urls import reverse_lazy +from django.http import HttpRequest, HttpResponse, HttpResponseForbidden +from django.shortcuts import redirect, render +from django.urls import reverse, reverse_lazy from django.utils.translation import gettext as _ from django.views.decorators.http import require_http_methods from django_htmx.http import HttpResponseClientRedirect, HttpResponseClientRefresh @@ -348,6 +344,20 @@ def submissions_all( return render(request, template_name, ctx) +@login_required +@require_http_methods(["GET"]) +def bulk_archive_submissions_confirm(request): + if not permissions.can_bulk_archive_submissions(request.user): + return HttpResponseForbidden() + + submission_ids = request.GET.getlist("selectedSubmissionIds") + return render( + request, + "submissions/bulk_archive_confirm.html", + {"submission_ids": submission_ids}, + ) + + @login_required @require_http_methods(["POST"]) def bulk_archive_submissions(request): @@ -363,7 +373,23 @@ def bulk_archive_submissions(request): request=request, ) - return HttpResponseClientRefresh() + if request.htmx: + return HttpResponseClientRefresh() + return redirect(reverse("apply:submissions:list")) + + +@login_required +@require_http_methods(["GET"]) +def bulk_delete_submissions_confirm(request): + if not permissions.can_bulk_delete_submissions(request.user): + return HttpResponseForbidden() + + submission_ids = request.GET.getlist("selectedSubmissionIds") + return render( + request, + "submissions/bulk_delete_confirm.html", + {"submission_ids": submission_ids}, + ) @login_required @@ -381,7 +407,9 @@ def bulk_delete_submissions(request): request=request, ) - return HttpResponseClientRefresh() + if request.htmx: + return HttpResponseClientRefresh() + return redirect(reverse("apply:submissions:list")) @login_required diff --git a/hypha/templates/cotton/modal/confirm.html b/hypha/templates/cotton/modal/confirm.html index e7c5a3f181..d43de7ad22 100644 --- a/hypha/templates/cotton/modal/confirm.html +++ b/hypha/templates/cotton/modal/confirm.html @@ -2,7 +2,7 @@
From f2727ef77a4163195f2327a4b99c4a7ad46eba23 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Fri, 1 May 2026 21:02:05 +0200 Subject: [PATCH 2/4] Proper confirm dialogs for batch anonymise of submissions. --- .../funds/templates/submissions/all.html | 5 ++- .../submissions/bulk_anonymize_confirm.html | 19 +++++++++ hypha/apply/funds/urls.py | 6 +++ hypha/apply/funds/views/all.py | 41 +++++++++++++------ 4 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 hypha/apply/funds/templates/submissions/bulk_anonymize_confirm.html diff --git a/hypha/apply/funds/templates/submissions/all.html b/hypha/apply/funds/templates/submissions/all.html index 6566f469cb..d84de2f083 100644 --- a/hypha/apply/funds/templates/submissions/all.html +++ b/hypha/apply/funds/templates/submissions/all.html @@ -504,9 +504,10 @@ {% if SUBMISSION_ANONYMIZATION_ENABLED %}