From 7fe12d1a22cb077d93a6695da36f9ca0f72ac611 Mon Sep 17 00:00:00 2001 From: Erin Song <121973038+erinysong@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:19:26 -0800 Subject: [PATCH] Add alerts to deleting domain invitations --- src/registrar/admin.py | 13 +++++++++++++ .../domain_invitation_delete_confirmation.html | 16 ++++++++++++++++ ..._invitation_delete_selected_confirmation.html | 16 ++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/registrar/templates/django/admin/domain_invitation_delete_selected_confirmation.html diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 407532943..bb7c26fa8 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1507,6 +1507,8 @@ class DomainInvitationAdmin(BaseInvitationAdmin): autocomplete_fields = ["domain"] change_form_template = "django/admin/domain_invitation_change_form.html" + # Override for the delete confirmation page on the domain table (bulk delete action) + delete_selected_confirmation_template = "django/admin/domain_invitation_delete_selected_confirmation.html" # Select domain invitations to change -> Domain invitations def changelist_view(self, request, extra_context=None): @@ -1515,6 +1517,17 @@ class DomainInvitationAdmin(BaseInvitationAdmin): extra_context["tabtitle"] = "Domain invitations" # Get the filtered values return super().changelist_view(request, extra_context=extra_context) + + + def delete_view(self, request, object_id, extra_context=None): + """ + Custom delete_view to perform additional actions or customize the template. + """ + # Set the delete template to a custom one + self.delete_confirmation_template = "django/admin/domain_invitation_delete_confirmation.html" + response = super().delete_view(request, object_id, extra_context=extra_context) + + return response def save_model(self, request, obj, form, change): """ diff --git a/src/registrar/templates/django/admin/domain_invitation_delete_confirmation.html b/src/registrar/templates/django/admin/domain_invitation_delete_confirmation.html index e69de29bb..abd0721de 100644 --- a/src/registrar/templates/django/admin/domain_invitation_delete_confirmation.html +++ b/src/registrar/templates/django/admin/domain_invitation_delete_confirmation.html @@ -0,0 +1,16 @@ +{% extends 'admin/delete_confirmation.html' %} +{% load i18n static %} + +{% block content_subtitle %} +
+ If you cancel the domain invitation here, it won't trigger any emails. It also won't remove + their domain management privileges if they already have that role assigned. Go to the + User Domain Roles table + if you want to remove the user from a domain. +
++ If you cancel the domain invitation here, it won't trigger any emails. It also won't remove + their domain management privileges if they already have that role assigned. Go to the + User Domain Roles table + if you want to remove the user from a domain. +
+