From 7e918ff537e517f8d70eab13396638ba711b07ad Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 7 Sep 2023 17:33:37 -0400 Subject: [PATCH] admin: add favicon, fix button height bug, remove link from table caption, add search helper text to logentry, remove submit buttons from logentry --- src/registrar/admin.py | 13 ++++++++++++ src/registrar/assets/sass/_theme/_admin.scss | 8 +++++--- src/registrar/templates/admin/app_list.html | 6 ++++-- src/registrar/templates/admin/base_site.html | 18 +++++++++++++++++ .../templates/admin/change_form.html | 2 +- .../admin/change_form_no_submit.html | 20 +++++++++++++++++++ 6 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 src/registrar/templates/admin/change_form_no_submit.html diff --git a/src/registrar/admin.py b/src/registrar/admin.py index d6109a0cc..7b798e692 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -6,9 +6,20 @@ from django.http.response import HttpResponseRedirect from django.urls import reverse from registrar.models.utility.admin_sort_fields import AdminSortFields from . import models +from auditlog.models import LogEntry # type: ignore +from auditlog.admin import LogEntryAdmin # type: ignore + logger = logging.getLogger(__name__) +class CustomLogEntryAdmin(LogEntryAdmin): + # Overwrite the generated LogEntry admin class + + search_help_text = "Search by resource, changed field, or user." + + change_form_template = 'admin/change_form_no_submit.html' + add_form_template = 'admin/change_form_no_submit.html' + class AuditedAdmin(admin.ModelAdmin, AdminSortFields): """Custom admin to make auditing easier.""" @@ -400,6 +411,8 @@ class DomainApplicationAdmin(ListHeaderAdmin): return super().change_view(request, object_id, form_url, extra_context) +admin.site.unregister(LogEntry) # Unregister the default registration +admin.site.register(LogEntry, CustomLogEntryAdmin) admin.site.register(models.User, MyUserAdmin) admin.site.register(models.UserDomainRole, AuditedAdmin) admin.site.register(models.Contact, ContactAdmin) diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index b87257344..739e3578d 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -140,7 +140,7 @@ h1, h2, h3 { font-weight: font-weight('bold'); } -table > caption > a { +table > caption > span { font-weight: font-weight('bold'); text-transform: none; } @@ -158,8 +158,10 @@ table > caption > a { padding-top: 20px; } -// 'Delete button' layout bug -.submit-row a.deletelink { +// Fix django admin button height bugs +.submit-row a.deletelink, +.delete-confirmation form .cancel-link, +.submit-row a.closelink { height: auto!important; } diff --git a/src/registrar/templates/admin/app_list.html b/src/registrar/templates/admin/app_list.html index fb5934470..3b402827e 100644 --- a/src/registrar/templates/admin/app_list.html +++ b/src/registrar/templates/admin/app_list.html @@ -4,11 +4,13 @@ {% for app in app_list %}
+ {# .gov override: remove link #} + {# end .gov override #} - {# .gov override #} + {# .gov override: add headers #} diff --git a/src/registrar/templates/admin/base_site.html b/src/registrar/templates/admin/base_site.html index 6b641722f..dcdd29e2f 100644 --- a/src/registrar/templates/admin/base_site.html +++ b/src/registrar/templates/admin/base_site.html @@ -2,6 +2,24 @@ {% load static %} {% load i18n %} +{% block extrahead %} + + + + + +{% endblock %} + {% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} {% block extrastyle %}{{ block.super }} diff --git a/src/registrar/templates/admin/change_form.html b/src/registrar/templates/admin/change_form.html index e0f9ae1a4..78dac9ac0 100644 --- a/src/registrar/templates/admin/change_form.html +++ b/src/registrar/templates/admin/change_form.html @@ -9,4 +9,4 @@ {% endblock %} {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/registrar/templates/admin/change_form_no_submit.html b/src/registrar/templates/admin/change_form_no_submit.html new file mode 100644 index 000000000..04a491aae --- /dev/null +++ b/src/registrar/templates/admin/change_form_no_submit.html @@ -0,0 +1,20 @@ +{% extends "admin/change_form.html" %} + +{% comment %} Replace the Django ul markup with a div. We'll edit the child markup accordingly in change_form_object_tools {% endcomment %} +{% block object-tools %} +{% if change and not is_popup %} +
+ {% block object-tools-items %} + {{ block.super }} + {% endblock %} +
+{% endif %} +{% endblock %} + +{% block submit_buttons_top %} + {# Do not render the submit buttons #} +{% endblock %} + +{% block submit_buttons_bottom %} + {# Do not render the submit buttons #} +{% endblock %}
- {{ app.name }} + {{ app.name }}
Model