mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 11:16:07 +02:00
Delete functionality
This commit is contained in:
parent
5ebae382ed
commit
403bfb6433
5 changed files with 51 additions and 27 deletions
|
@ -138,6 +138,11 @@ urlpatterns = [
|
||||||
views.DomainInvitationDeleteView.as_view(http_method_names=["post"]),
|
views.DomainInvitationDeleteView.as_view(http_method_names=["post"]),
|
||||||
name="invitation-delete",
|
name="invitation-delete",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"application/<int:pk>/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
|
# we normally would guard these with `if settings.DEBUG` but tests run with
|
||||||
|
|
|
@ -141,36 +141,32 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url 'application-status' application.pk %}">
|
<a
|
||||||
|
id="button-toggle-delete-domain-alert-{{ forloop.counter }}"
|
||||||
|
href="#toggle-delete-domain-alert-{{ forloop.counter }}"
|
||||||
|
class="usa-button--unstyled"
|
||||||
|
aria-controls="toggle-delete-domain-alert-{{ forloop.counter }}"
|
||||||
|
data-open-modal
|
||||||
|
>
|
||||||
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
||||||
|
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
|
||||||
|
</svg>
|
||||||
Delete
|
Delete
|
||||||
</a>
|
</a>
|
||||||
<a
|
|
||||||
id="button-toggle-delete-domain-alert-{{ forloop.counter }}"
|
|
||||||
href="#toggle-delete-domain-alert-{{ forloop.counter }}"
|
|
||||||
class="usa-button--unstyled"
|
|
||||||
aria-controls="toggle-delete-domain-alert-{{ forloop.counter }}"
|
|
||||||
data-open-modal
|
|
||||||
>
|
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#delete"></use>
|
|
||||||
</svg>
|
|
||||||
Delete
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="usa-modal"
|
class="usa-modal"
|
||||||
id="toggle-delete-domain-alert-{{ forloop.counter }}"
|
id="toggle-delete-domain-alert-{{ forloop.counter }}"
|
||||||
aria-labelledby="Are you sure you want to continue?"
|
aria-labelledby="Are you sure you want to continue?"
|
||||||
aria-describedby="User will be removed"
|
aria-describedby="User will be removed"
|
||||||
data-force-action
|
data-force-action
|
||||||
>
|
>
|
||||||
<form method="POST" action="{% url "domain-user-delete" pk=domain.id user_pk=permission.user.id %}">
|
<form method="POST" action="{% url "application-delete" pk=application.id %}">
|
||||||
{% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %}
|
{% 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="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %}
|
{% 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 %}
|
{% endwith %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -12,6 +12,7 @@ from registrar.forms import application_wizard as forms
|
||||||
from registrar.models import DomainApplication
|
from registrar.models import DomainApplication
|
||||||
from registrar.utility import StrEnum
|
from registrar.utility import StrEnum
|
||||||
from registrar.views.utility import StepsHelper
|
from registrar.views.utility import StepsHelper
|
||||||
|
from registrar.views.utility.permission_views import DomainApplicationPermissionDeleteView
|
||||||
|
|
||||||
from .utility import (
|
from .utility import (
|
||||||
DomainApplicationPermissionView,
|
DomainApplicationPermissionView,
|
||||||
|
@ -572,3 +573,10 @@ class ApplicationWithdrawn(DomainApplicationPermissionWithdrawView):
|
||||||
application.withdraw()
|
application.withdraw()
|
||||||
application.save()
|
application.save()
|
||||||
return HttpResponseRedirect(reverse("home"))
|
return HttpResponseRedirect(reverse("home"))
|
||||||
|
|
||||||
|
|
||||||
|
class DomainApplicationDeleteView(DomainApplicationPermissionDeleteView):
|
||||||
|
object: DomainApplication # workaround for type mismatch in DeleteView
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse("home")
|
|
@ -18,4 +18,11 @@ def index(request):
|
||||||
domains = Domain.objects.filter(id__in=domain_ids)
|
domains = Domain.objects.filter(id__in=domain_ids)
|
||||||
|
|
||||||
context["domains"] = domains
|
context["domains"] = domains
|
||||||
|
modal_button = (
|
||||||
|
'<button type="submit" '
|
||||||
|
'class="usa-button usa-button--secondary" '
|
||||||
|
'name="delete-application">Yes, delete request</button>'
|
||||||
|
)
|
||||||
|
|
||||||
|
context["modal_button"] = modal_button
|
||||||
return render(request, "home.html", context)
|
return render(request, "home.html", context)
|
||||||
|
|
|
@ -122,3 +122,11 @@ class DomainInvitationPermissionDeleteView(DomainInvitationPermission, DeleteVie
|
||||||
|
|
||||||
model = DomainInvitation
|
model = DomainInvitation
|
||||||
object: DomainInvitation # workaround for type mismatch in DeleteView
|
object: DomainInvitation # workaround for type mismatch in DeleteView
|
||||||
|
|
||||||
|
|
||||||
|
class DomainApplicationPermissionDeleteView(DomainApplicationPermission, DeleteView, abc.ABC):
|
||||||
|
|
||||||
|
"""Abstract view for deleting a DomainApplication."""
|
||||||
|
|
||||||
|
model = DomainApplication
|
||||||
|
object: DomainApplication
|
Loading…
Add table
Add a link
Reference in a new issue