mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 22:44:11 +02:00
Add logic for self deletion
This commit is contained in:
parent
0618a72c11
commit
40e91ead1f
3 changed files with 69 additions and 47 deletions
|
@ -26,18 +26,21 @@ a.usa-button {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.usa-button.disabled-link {
|
a.usa-button.disabled-link,
|
||||||
|
a.usa-button--unstyled.disabled-link {
|
||||||
background-color: #ccc !important;
|
background-color: #ccc !important;
|
||||||
color: #454545 !important
|
color: #454545 !important
|
||||||
}
|
}
|
||||||
|
|
||||||
a.usa-button.disabled-link:hover {
|
a.usa-button.disabled-link:hover,
|
||||||
|
a.usa-button--unstyled.disabled-link {
|
||||||
background-color: #ccc !important;
|
background-color: #ccc !important;
|
||||||
cursor: not-allowed !important;
|
cursor: not-allowed !important;
|
||||||
color: #454545 !important
|
color: #454545 !important
|
||||||
}
|
}
|
||||||
|
|
||||||
a.usa-button.disabled-link:focus {
|
a.usa-button.disabled-link:focus,
|
||||||
|
a.usa-button--unstyled.disabled-link {
|
||||||
background-color: #ccc !important;
|
background-color: #ccc !important;
|
||||||
cursor: not-allowed !important;
|
cursor: not-allowed !important;
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
|
|
|
@ -16,10 +16,8 @@
|
||||||
<li>There is no limit to the number of domain managers you can add.</li>
|
<li>There is no limit to the number of domain managers you can add.</li>
|
||||||
<li>After adding a domain manager, an email invitation will be sent to that user with
|
<li>After adding a domain manager, an email invitation will be sent to that user with
|
||||||
instructions on how to set up an account.</li>
|
instructions on how to set up an account.</li>
|
||||||
<li>To remove a domain manager, <a href="{% public_site_url 'contact/' %}"
|
|
||||||
target="_blank" rel="noopener noreferrer" class="usa-link">contact us</a> for
|
|
||||||
assistance.</li>
|
|
||||||
<li>All domain managers must keep their contact information updated and be responsive if contacted by the .gov team.</li>
|
<li>All domain managers must keep their contact information updated and be responsive if contacted by the .gov team.</li>
|
||||||
|
<li>Domains must have at least one domain manager. You can’t remove yourself as a domain manager if you’re the only one assigned to this domain. Add another domain manager before you remove yourself from this domain.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% if domain.permissions %}
|
{% if domain.permissions %}
|
||||||
|
@ -31,9 +29,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sortable scope="col" role="columnheader">Email</th>
|
<th data-sortable scope="col" role="columnheader">Email</th>
|
||||||
<th data-sortable scope="col" role="columnheader">Role</th>
|
<th data-sortable scope="col" role="columnheader">Role</th>
|
||||||
{% if can_delete_users %}
|
|
||||||
<th scope="col" role="columnheader"><span class="sr-only">Action</span></th>
|
<th scope="col" role="columnheader"><span class="sr-only">Action</span></th>
|
||||||
{% endif %}
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -43,8 +39,8 @@
|
||||||
{{ permission.user.email }}
|
{{ permission.user.email }}
|
||||||
</th>
|
</th>
|
||||||
<td data-label="Role">{{ permission.role|title }}</td>
|
<td data-label="Role">{{ permission.role|title }}</td>
|
||||||
{% if can_delete_users %}
|
|
||||||
<td class="shift-action-button">
|
<td class="shift-action-button">
|
||||||
|
{% if can_delete_users %}
|
||||||
<a
|
<a
|
||||||
id="button-toggle-user-alert-{{ forloop.counter }}"
|
id="button-toggle-user-alert-{{ forloop.counter }}"
|
||||||
href="#toggle-user-alert-{{ forloop.counter }}"
|
href="#toggle-user-alert-{{ forloop.counter }}"
|
||||||
|
@ -78,14 +74,31 @@
|
||||||
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 "domain-user-delete" pk=domain.id user_pk=permission.user.id %}">
|
||||||
{% with email=permission.user.email|force_escape domain_name=domain.name|force_escape %}
|
{% with email=permission.user.email|default:permission.user|force_escape domain_name=domain.name|force_escape %}
|
||||||
{% include 'includes/modal.html' with modal_heading="Are you sure you want to remove <"|add:email|add:">?"|safe modal_description="<strong><"|add:email|add:"></strong> will no longer be able to manage the domain <strong>"|add:domain_name|add:"</strong>."|safe modal_button=modal_button|safe %}
|
{% include 'includes/modal.html' with modal_heading="Are you sure you want to remove <"|add:email|add:">?"|safe modal_description="<strong><"|add:email|add:"></strong> will no longer be able to manage the domain <strong>"|add:domain_name|add:"</strong>."|safe modal_button=modal_button|safe %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
{% else %}
|
||||||
|
<a
|
||||||
|
class="usa-button--unstyled disabled-link usa-tooltip text-no-underline "
|
||||||
|
data-position="top"
|
||||||
|
title="Domains must have at least one domain manager"
|
||||||
|
aria-disabled="true"
|
||||||
|
data-tooltip="true"
|
||||||
|
>
|
||||||
|
Remove
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% comment %}
|
||||||
|
usa-tooltip disabled-link"
|
||||||
|
data-position="right"
|
||||||
|
title="Coming in 2024"
|
||||||
|
aria-disabled="true"
|
||||||
|
data-tooltip="true"
|
||||||
|
{% endcomment %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -820,13 +820,18 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView):
|
||||||
return UserDomainRole.objects.get(domain=domain_id, user=user_id)
|
return UserDomainRole.objects.get(domain=domain_id, user=user_id)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
|
"""Refreshes the page after a delete is successful"""
|
||||||
return reverse("domain-users", kwargs={"pk": self.object.domain.id})
|
return reverse("domain-users", kwargs={"pk": self.object.domain.id})
|
||||||
|
|
||||||
def get_success_message(self, delete_self = False):
|
def get_success_message(self, delete_self = False):
|
||||||
|
"""Returns confirmation content for the deletion event """
|
||||||
|
email_or_name = self.object.user.email
|
||||||
|
if email_or_name is None:
|
||||||
|
email_or_name = self.object.user
|
||||||
if delete_self:
|
if delete_self:
|
||||||
message = f"You are no longer managing the domain {self.object.domain}."
|
message = f"You are no longer managing the domain {self.object.domain}."
|
||||||
else:
|
else:
|
||||||
message = f"Removed {self.object.user.email} as a manager for this domain."
|
message = f"Removed {email_or_name} as a manager for this domain."
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -842,10 +847,11 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView):
|
||||||
return redirect(self.get_success_url())
|
return redirect(self.get_success_url())
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
"""Custom post implementation to redirect to home in the event that the user deletes themselves"""
|
||||||
response = super().post(request, *args, **kwargs)
|
response = super().post(request, *args, **kwargs)
|
||||||
|
|
||||||
# If the user is deleting themselves, redirect to home
|
# If the user is deleting themselves, redirect to home
|
||||||
if self.request.user.email == self.object.user.email:
|
if self.request.user == self.object.user:
|
||||||
return redirect(reverse("home"))
|
return redirect(reverse("home"))
|
||||||
|
|
||||||
return response
|
return response
|
Loading…
Add table
Add a link
Reference in a new issue