mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-04 18:23:29 +02:00
Cleanup
This commit is contained in:
parent
1a9002c1b4
commit
75b34dab3b
15 changed files with 175 additions and 221 deletions
|
@ -1245,7 +1245,6 @@ class UserDomainRoleResource(resources.ModelResource):
|
||||||
|
|
||||||
class UserPortfolioPermissionAdmin(ListHeaderAdmin):
|
class UserPortfolioPermissionAdmin(ListHeaderAdmin):
|
||||||
form = UserPortfolioPermissionsForm
|
form = UserPortfolioPermissionsForm
|
||||||
change_form_template = "django/admin/user_portfolio_permission_change_form.html"
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Contains meta information about this class"""
|
"""Contains meta information about this class"""
|
||||||
|
@ -1263,14 +1262,6 @@ class UserPortfolioPermissionAdmin(ListHeaderAdmin):
|
||||||
|
|
||||||
autocomplete_fields = ["user", "portfolio"]
|
autocomplete_fields = ["user", "portfolio"]
|
||||||
|
|
||||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
|
||||||
"""Adds a readonly display for roles and permissions"""
|
|
||||||
obj = self.get_object(request, object_id)
|
|
||||||
extra_context = extra_context or {}
|
|
||||||
extra_context["display_roles"] = ", ".join(obj.get_readable_roles())
|
|
||||||
extra_context["display_permissions"] = ", ".join(obj.get_readable_additional_permissions())
|
|
||||||
return super().change_view(request, object_id, form_url, extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class UserDomainRoleAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
class UserDomainRoleAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"""Custom user domain role admin class."""
|
"""Custom user domain role admin class."""
|
||||||
|
|
|
@ -82,20 +82,6 @@ class UserPortfolioPermission(TimeStampedModel):
|
||||||
)
|
)
|
||||||
return f"{self.user}" f" <Roles: {', '.join(readable_roles)}>" if self.roles else ""
|
return f"{self.user}" f" <Roles: {', '.join(readable_roles)}>" if self.roles else ""
|
||||||
|
|
||||||
def get_readable_roles(self):
|
|
||||||
"""Returns a list of labels of each role in self.roles"""
|
|
||||||
role_labels = []
|
|
||||||
for role in self.roles:
|
|
||||||
role_labels.append(UserPortfolioRoleChoices.get_user_portfolio_role_label(role))
|
|
||||||
return role_labels
|
|
||||||
|
|
||||||
def get_readable_additional_permissions(self):
|
|
||||||
"""Returns a list of labels of each additional_permission in self.additional_permissions"""
|
|
||||||
perm_labels = []
|
|
||||||
for perm in self.additional_permissions:
|
|
||||||
perm_labels.append(UserPortfolioPermissionChoices.get_user_portfolio_permission_label(perm))
|
|
||||||
return perm_labels
|
|
||||||
|
|
||||||
def _get_portfolio_permissions(self):
|
def _get_portfolio_permissions(self):
|
||||||
"""
|
"""
|
||||||
Retrieve the permissions for the user's portfolio roles.
|
Retrieve the permissions for the user's portfolio roles.
|
||||||
|
|
|
@ -49,6 +49,8 @@ class CheckUserProfileMiddleware:
|
||||||
self.setup_page,
|
self.setup_page,
|
||||||
self.logout_page,
|
self.logout_page,
|
||||||
"/admin",
|
"/admin",
|
||||||
|
# These are here as there is a bug with this middleware that breaks djangos built in debug console.
|
||||||
|
# The debug console uses this directory, but since this overrides that, it throws errors.
|
||||||
"/__debug__",
|
"/__debug__",
|
||||||
]
|
]
|
||||||
self.other_excluded_pages = [
|
self.other_excluded_pages = [
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
{% comment %} This view provides a detail button that can be used to show/hide content {% endcomment %}
|
||||||
|
<details class="margin-top-1 dja-detail-table" aria-role="button" {% if start_open %}open{% else %}closed{% endif %}>
|
||||||
|
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
||||||
|
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
||||||
|
{% block detail_content %}
|
||||||
|
{% endblock detail_content%}
|
||||||
|
</div>
|
||||||
|
</details>
|
|
@ -0,0 +1,48 @@
|
||||||
|
{% extends "django/admin/includes/details_button.html" %}
|
||||||
|
{% load static url_helpers %}
|
||||||
|
|
||||||
|
{% block detail_content %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Phone</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for admin in admins %}
|
||||||
|
{% url 'admin:registrar_userportfoliopermission_change' admin.pk as url %}
|
||||||
|
<tr>
|
||||||
|
<td><a href={{url}}>{{ admin.user.get_formatted_name}}</a></td>
|
||||||
|
<td>{{ admin.user.title }}</td>
|
||||||
|
<td>
|
||||||
|
{% if admin.user.email %}
|
||||||
|
{{ admin.user.email }}
|
||||||
|
{% else %}
|
||||||
|
None
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{{ admin.user.phone }}</td>
|
||||||
|
<td class="padding-left-1 text-size-small">
|
||||||
|
{% if admin.user.email %}
|
||||||
|
<input aria-hidden="true" class="display-none" value="{{ admin.user.email }}" />
|
||||||
|
<button
|
||||||
|
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="usa-icon"
|
||||||
|
>
|
||||||
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
|
</svg>
|
||||||
|
<span>Copy email</span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock detail_content %}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% extends "django/admin/includes/details_button.html" %}
|
||||||
|
{% load static url_helpers %}
|
||||||
|
|
||||||
|
{% block detail_content %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for domain_request in domain_requests %}
|
||||||
|
{% url 'admin:registrar_domainrequest_change' domain_request.pk as url %}
|
||||||
|
<tr>
|
||||||
|
<td><a href={{url}}>{{ domain_request }}</a></td>
|
||||||
|
{% if domain_request.get_status_display %}
|
||||||
|
<td>{{ domain_request.get_status_display }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td>None</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock detail_content %}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{% extends "django/admin/includes/details_button.html" %}
|
||||||
|
{% load static url_helpers %}
|
||||||
|
|
||||||
|
{% block detail_content %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>State</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for domain_info in domains %}
|
||||||
|
{% if domain_info.domain %}
|
||||||
|
{% with domain=domain_info.domain %}
|
||||||
|
{% url 'admin:registrar_domain_change' domain.pk as url %}
|
||||||
|
<tr>
|
||||||
|
<td><a href={{url}}>{{ domain }}</a></td>
|
||||||
|
{% if domain and domain.get_state_display %}
|
||||||
|
<td>{{ domain.get_state_display }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td>None</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock detail_content%}
|
|
@ -43,19 +43,19 @@
|
||||||
</div>
|
</div>
|
||||||
{% elif field.field.name == "display_admins" %}
|
{% elif field.field.name == "display_admins" %}
|
||||||
{% if admins|length > 0 %}
|
{% if admins|length > 0 %}
|
||||||
{% include "django/admin/includes/portfolio_admins_table.html" with admins=admins %}
|
{% include "django/admin/includes/portfolio/portfolio_admins_table.html" with admins=admins %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif field.field.name == "display_members" %}
|
{% elif field.field.name == "display_members" %}
|
||||||
{% if members|length > 0 %}
|
{% if members|length > 0 %}
|
||||||
{% include "django/admin/includes/portfolio_members_table.html" with members=members %}
|
{% include "django/admin/includes/portfolio/portfolio_members_table.html" with members=members %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif field.field.name == "domains" %}
|
{% elif field.field.name == "domains" %}
|
||||||
{% if domains|length > 0 %}
|
{% if domains|length > 0 %}
|
||||||
{% include "django/admin/includes/portfolio_domains_table.html" with domains=domains %}
|
{% include "django/admin/includes/portfolio/portfolio_domains_table.html" with domains=domains %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif field.field.name == "domain_requests" %}
|
{% elif field.field.name == "domain_requests" %}
|
||||||
{% if domain_requests|length > 0 %}
|
{% if domain_requests|length > 0 %}
|
||||||
{% include "django/admin/includes/portfolio_domain_requests_table.html" with domain_requests=domain_requests %}
|
{% include "django/admin/includes/portfolio/portfolio_domain_requests_table.html" with domain_requests=domain_requests %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock after_help_text %}
|
{% endblock after_help_text %}
|
|
@ -0,0 +1,55 @@
|
||||||
|
{% extends "django/admin/includes/details_button.html" %}
|
||||||
|
{% load custom_filters %}
|
||||||
|
{% load static url_helpers %}
|
||||||
|
|
||||||
|
{% block detail_content %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Phone</th>
|
||||||
|
<th>Roles</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for member in members %}
|
||||||
|
{% url 'admin:registrar_userportfoliopermission_change' member.pk as url %}
|
||||||
|
<tr>
|
||||||
|
<td><a href={{url}}>{{ member.user.get_formatted_name}}</a></td>
|
||||||
|
<td>{{ member.user.title }}</td>
|
||||||
|
<td>
|
||||||
|
{% if member.user.email %}
|
||||||
|
{{ member.user.email }}
|
||||||
|
{% else %}
|
||||||
|
None
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{{ member.user.phone }}</td>
|
||||||
|
<td>
|
||||||
|
{% for role in member.user|portfolio_role_summary:original %}
|
||||||
|
<span class="usa-tag">{{ role }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
<td class="padding-left-1 text-size-small">
|
||||||
|
{% if member.user.email %}
|
||||||
|
<input aria-hidden="true" class="display-none" value="{{ member.user.email }}" />
|
||||||
|
<button
|
||||||
|
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="usa-icon"
|
||||||
|
>
|
||||||
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
|
</svg>
|
||||||
|
<span>Copy email</span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
|
@ -1,50 +0,0 @@
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
<details class="margin-top-1 dja-detail-table" aria-role="button" closed>
|
|
||||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
|
||||||
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Title</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Phone</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for admin in admins %}
|
|
||||||
{% url 'admin:registrar_userportfoliopermission_change' admin.pk as url %}
|
|
||||||
<tr>
|
|
||||||
<td><a href={{url}}>{{ admin.user.get_formatted_name}}</a></td>
|
|
||||||
<td>{{ admin.user.title }}</td>
|
|
||||||
<td>
|
|
||||||
{% if admin.user.email %}
|
|
||||||
{{ admin.user.email }}
|
|
||||||
{% else %}
|
|
||||||
None
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>{{ admin.user.phone }}</td>
|
|
||||||
<td class="padding-left-1 text-size-small">
|
|
||||||
{% if admin.user.email %}
|
|
||||||
<input aria-hidden="true" class="display-none" value="{{ admin.user.email }}" />
|
|
||||||
<button
|
|
||||||
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
class="usa-icon"
|
|
||||||
>
|
|
||||||
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
|
||||||
</svg>
|
|
||||||
<span>Copy email</span>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
|
@ -1,28 +0,0 @@
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
<details class="margin-top-1 dja-detail-table" aria-role="button" closed>
|
|
||||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
|
||||||
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Status</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for domain_request in domain_requests %}
|
|
||||||
{% url 'admin:registrar_domainrequest_change' domain_request.pk as url %}
|
|
||||||
<tr>
|
|
||||||
<td><a href={{url}}>{{ domain_request }}</a></td>
|
|
||||||
{% if domain_request.get_status_display %}
|
|
||||||
<td>{{ domain_request.get_status_display }}</td>
|
|
||||||
{% else %}
|
|
||||||
<td>None</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
|
@ -1,32 +0,0 @@
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
<details class="margin-top-1 dja-detail-table" aria-role="button" closed>
|
|
||||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
|
||||||
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>State</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for domain_info in domains %}
|
|
||||||
{% if domain_info.domain %}
|
|
||||||
{% with domain=domain_info.domain %}
|
|
||||||
{% url 'admin:registrar_domain_change' domain.pk as url %}
|
|
||||||
<tr>
|
|
||||||
<td><a href={{url}}>{{ domain }}</a></td>
|
|
||||||
{% if domain and domain.get_state_display %}
|
|
||||||
<td>{{ domain.get_state_display }}</td>
|
|
||||||
{% else %}
|
|
||||||
<td>None</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endwith %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
|
@ -1,57 +0,0 @@
|
||||||
{% load custom_filters %}
|
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
<details class="margin-top-1 dja-detail-table" aria-role="button" closed>
|
|
||||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
|
||||||
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Title</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Phone</th>
|
|
||||||
<th>Roles</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for member in members %}
|
|
||||||
{% url 'admin:registrar_userportfoliopermission_change' member.pk as url %}
|
|
||||||
<tr>
|
|
||||||
<td><a href={{url}}>{{ member.user.get_formatted_name}}</a></td>
|
|
||||||
<td>{{ member.user.title }}</td>
|
|
||||||
<td>
|
|
||||||
{% if member.user.email %}
|
|
||||||
{{ member.user.email }}
|
|
||||||
{% else %}
|
|
||||||
None
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>{{ member.user.phone }}</td>
|
|
||||||
<td>
|
|
||||||
{% for role in member.user|portfolio_role_summary:original %}
|
|
||||||
<span class="usa-tag">{{ role }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
<td class="padding-left-1 text-size-small">
|
|
||||||
{% if member.user.email %}
|
|
||||||
<input aria-hidden="true" class="display-none" value="{{ member.user.email }}" />
|
|
||||||
<button
|
|
||||||
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
class="usa-icon"
|
|
||||||
>
|
|
||||||
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
|
||||||
</svg>
|
|
||||||
<span>Copy email</span>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
|
@ -1,26 +0,0 @@
|
||||||
{% extends "django/admin/includes/detail_table_fieldset.html" %}
|
|
||||||
{% load custom_filters %}
|
|
||||||
{% load static url_helpers %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block field_readonly %}
|
|
||||||
{% if field.field.name == "roles" %}
|
|
||||||
<div class="readonly">
|
|
||||||
{% if display_roles %}
|
|
||||||
{{ display_roles }}
|
|
||||||
{% else %}
|
|
||||||
No roles found.
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% elif field.field.name == "additional_permissions" %}
|
|
||||||
<div class="readonly">
|
|
||||||
{% if display_permissions %}
|
|
||||||
{{ display_permissions }}
|
|
||||||
{% else %}
|
|
||||||
No additional permissions found.
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock field_readonly%}
|
|
|
@ -20,7 +20,7 @@
|
||||||
When extending the fieldset view consider whether you need to make a new one that extends from detail_table_fieldset.
|
When extending the fieldset view consider whether you need to make a new one that extends from detail_table_fieldset.
|
||||||
detail_table_fieldset is used on multiple admin pages, so a change there can have unintended consequences.
|
detail_table_fieldset is used on multiple admin pages, so a change there can have unintended consequences.
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% include "django/admin/includes/portfolio_fieldset.html" with original_object=original %}
|
{% include "django/admin/includes/portfolio/portfolio_fieldset.html" with original_object=original %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue