From 403bfb6433eb15242b4f5cc3f1dbfc98dcd002e8 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:34:08 -0700 Subject: [PATCH] Delete functionality --- src/registrar/config/urls.py | 5 ++ src/registrar/templates/home.html | 50 +++++++++---------- src/registrar/views/application.py | 8 +++ src/registrar/views/index.py | 7 +++ .../views/utility/permission_views.py | 8 +++ 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 607bf5f61..bbe91f6fd 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -138,6 +138,11 @@ urlpatterns = [ views.DomainInvitationDeleteView.as_view(http_method_names=["post"]), name="invitation-delete", ), + path( + "application//delete", + views.DomainApplicationDeleteView.as_view(http_method_names=["post"]), + name="application-delete", + ), ] # we normally would guard these with `if settings.DEBUG` but tests run with diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index 80b20c258..3a9a5a611 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -141,36 +141,32 @@ - - + + Delete - - - Delete - -
-
- {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} - {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} - {% endwith %} -
-
+
+
+ {% with heading="Are you sure you want to delete "|add:application.requested_domain.name|add:"?" %} + {% include 'includes/modal.html' with modal_heading=heading modal_description="This will remove the domain request from the .gov registrar. This action cannot be undone." modal_button=modal_button|safe %} + {% endwith %} +
+
{% endfor %} diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index 41052e164..63adbf3d9 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -12,6 +12,7 @@ from registrar.forms import application_wizard as forms from registrar.models import DomainApplication from registrar.utility import StrEnum from registrar.views.utility import StepsHelper +from registrar.views.utility.permission_views import DomainApplicationPermissionDeleteView from .utility import ( DomainApplicationPermissionView, @@ -572,3 +573,10 @@ class ApplicationWithdrawn(DomainApplicationPermissionWithdrawView): application.withdraw() application.save() return HttpResponseRedirect(reverse("home")) + + +class DomainApplicationDeleteView(DomainApplicationPermissionDeleteView): + object: DomainApplication # workaround for type mismatch in DeleteView + + def get_success_url(self): + return reverse("home") \ No newline at end of file diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index 9605c723d..a4a8e3d90 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -18,4 +18,11 @@ def index(request): domains = Domain.objects.filter(id__in=domain_ids) context["domains"] = domains + modal_button = ( + '' + ) + + context["modal_button"] = modal_button return render(request, "home.html", context) diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index 1798ec79d..cf6bd930d 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -122,3 +122,11 @@ class DomainInvitationPermissionDeleteView(DomainInvitationPermission, DeleteVie model = DomainInvitation object: DomainInvitation # workaround for type mismatch in DeleteView + + +class DomainApplicationPermissionDeleteView(DomainApplicationPermission, DeleteView, abc.ABC): + + """Abstract view for deleting a DomainApplication.""" + + model = DomainApplication + object: DomainApplication \ No newline at end of file