mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 03:30:50 +02:00
Merge pull request #3592 from cisagov/nl/3176-page-titles
#3176 - Standardize admin page titles [-KY]
This commit is contained in:
commit
f38daaca0c
3 changed files with 61 additions and 78 deletions
|
@ -163,6 +163,18 @@ class MyUserAdminForm(UserChangeForm):
|
||||||
"user_permissions": NoAutocompleteFilteredSelectMultiple("user_permissions", False),
|
"user_permissions": NoAutocompleteFilteredSelectMultiple("user_permissions", False),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Loads "tabtitle" for this admin page so that on render the <title>
|
||||||
|
# element will only have the model name instead of
|
||||||
|
# the default string loaded by native Django admin code.
|
||||||
|
# (Eg. instead of "Select contact to change", display "Contacts")
|
||||||
|
# see "base_site.html" for the <title> code.
|
||||||
|
def changelist_view(self, request, extra_context=None):
|
||||||
|
if extra_context is None:
|
||||||
|
extra_context = {}
|
||||||
|
extra_context["tabtitle"] = str(self.opts.verbose_name_plural).title()
|
||||||
|
# Get the filtered values
|
||||||
|
return super().changelist_view(request, extra_context=extra_context)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Custom init to modify the user form"""
|
"""Custom init to modify the user form"""
|
||||||
super(MyUserAdminForm, self).__init__(*args, **kwargs)
|
super(MyUserAdminForm, self).__init__(*args, **kwargs)
|
||||||
|
@ -523,6 +535,18 @@ class CustomLogEntryAdmin(LogEntryAdmin):
|
||||||
"user_url",
|
"user_url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Loads "tabtitle" for this admin page so that on render the <title>
|
||||||
|
# element will only have the model name instead of
|
||||||
|
# the default string loaded by native Django admin code.
|
||||||
|
# (Eg. instead of "Select contact to change", display "Contacts")
|
||||||
|
# see "base_site.html" for the <title> code.
|
||||||
|
def changelist_view(self, request, extra_context=None):
|
||||||
|
if extra_context is None:
|
||||||
|
extra_context = {}
|
||||||
|
extra_context["tabtitle"] = str(self.opts.verbose_name_plural).title()
|
||||||
|
# Get the filtered values
|
||||||
|
return super().changelist_view(request, extra_context=extra_context)
|
||||||
|
|
||||||
# We name the custom prop 'resource' because linter
|
# We name the custom prop 'resource' because linter
|
||||||
# is not allowing a short_description attr on it
|
# is not allowing a short_description attr on it
|
||||||
# This gets around the linter limitation, for now.
|
# This gets around the linter limitation, for now.
|
||||||
|
@ -542,13 +566,6 @@ class CustomLogEntryAdmin(LogEntryAdmin):
|
||||||
change_form_template = "admin/change_form_no_submit.html"
|
change_form_template = "admin/change_form_no_submit.html"
|
||||||
add_form_template = "admin/change_form_no_submit.html"
|
add_form_template = "admin/change_form_no_submit.html"
|
||||||
|
|
||||||
# Select log entry to change -> Log entries
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Log entries"
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
# #786: Skipping on updating audit log tab titles for now
|
# #786: Skipping on updating audit log tab titles for now
|
||||||
# def change_view(self, request, object_id, form_url="", extra_context=None):
|
# def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||||
# if extra_context is None:
|
# if extra_context is None:
|
||||||
|
@ -629,6 +646,18 @@ class AdminSortFields:
|
||||||
class AuditedAdmin(admin.ModelAdmin):
|
class AuditedAdmin(admin.ModelAdmin):
|
||||||
"""Custom admin to make auditing easier."""
|
"""Custom admin to make auditing easier."""
|
||||||
|
|
||||||
|
# Loads "tabtitle" for this admin page so that on render the <title>
|
||||||
|
# element will only have the model name instead of
|
||||||
|
# the default string loaded by native Django admin code.
|
||||||
|
# (Eg. instead of "Select contact to change", display "Contacts")
|
||||||
|
# see "base_site.html" for the <title> code.
|
||||||
|
def changelist_view(self, request, extra_context=None):
|
||||||
|
if extra_context is None:
|
||||||
|
extra_context = {}
|
||||||
|
extra_context["tabtitle"] = str(self.opts.verbose_name_plural).title()
|
||||||
|
# Get the filtered values
|
||||||
|
return super().changelist_view(request, extra_context=extra_context)
|
||||||
|
|
||||||
def history_view(self, request, object_id, extra_context=None):
|
def history_view(self, request, object_id, extra_context=None):
|
||||||
"""On clicking 'History', take admin to the auditlog view for an object."""
|
"""On clicking 'History', take admin to the auditlog view for an object."""
|
||||||
return HttpResponseRedirect(
|
return HttpResponseRedirect(
|
||||||
|
@ -1029,6 +1058,18 @@ class MyUserAdmin(BaseUserAdmin, ImportExportModelAdmin):
|
||||||
extra_context = {"domain_requests": domain_requests, "domains": domains, "portfolios": portfolios}
|
extra_context = {"domain_requests": domain_requests, "domains": domains, "portfolios": portfolios}
|
||||||
return super().change_view(request, object_id, form_url, extra_context)
|
return super().change_view(request, object_id, form_url, extra_context)
|
||||||
|
|
||||||
|
# Loads "tabtitle" for this admin page so that on render the <title>
|
||||||
|
# element will only have the model name instead of
|
||||||
|
# the default string loaded by native Django admin code.
|
||||||
|
# (Eg. instead of "Select contact to change", display "Contacts")
|
||||||
|
# see "base_site.html" for the <title> code.
|
||||||
|
def changelist_view(self, request, extra_context=None):
|
||||||
|
if extra_context is None:
|
||||||
|
extra_context = {}
|
||||||
|
extra_context["tabtitle"] = str(self.opts.verbose_name_plural).title()
|
||||||
|
# Get the filtered values
|
||||||
|
return super().changelist_view(request, extra_context=extra_context)
|
||||||
|
|
||||||
|
|
||||||
class HostIPInline(admin.StackedInline):
|
class HostIPInline(admin.StackedInline):
|
||||||
"""Edit an ip address on the host page."""
|
"""Edit an ip address on the host page."""
|
||||||
|
@ -1053,14 +1094,6 @@ class MyHostAdmin(AuditedAdmin, ImportExportModelAdmin):
|
||||||
search_help_text = "Search by domain or host name."
|
search_help_text = "Search by domain or host name."
|
||||||
inlines = [HostIPInline]
|
inlines = [HostIPInline]
|
||||||
|
|
||||||
# Select host to change -> Host
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Host"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class HostIpResource(resources.ModelResource):
|
class HostIpResource(resources.ModelResource):
|
||||||
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
||||||
|
@ -1076,14 +1109,6 @@ class HostIpAdmin(AuditedAdmin, ImportExportModelAdmin):
|
||||||
resource_classes = [HostIpResource]
|
resource_classes = [HostIpResource]
|
||||||
model = models.HostIP
|
model = models.HostIP
|
||||||
|
|
||||||
# Select host ip to change -> Host ip
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Host IP"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class ContactResource(resources.ModelResource):
|
class ContactResource(resources.ModelResource):
|
||||||
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
||||||
|
@ -1205,14 +1230,6 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
return super().change_view(request, object_id, form_url, extra_context=extra_context)
|
return super().change_view(request, object_id, form_url, extra_context=extra_context)
|
||||||
|
|
||||||
# Select contact to change -> Contacts
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Contacts"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
# Clear warning messages before saving
|
# Clear warning messages before saving
|
||||||
storage = messages.get_messages(request)
|
storage = messages.get_messages(request)
|
||||||
|
@ -1527,14 +1544,6 @@ class DomainInvitationAdmin(BaseInvitationAdmin):
|
||||||
# Override for the delete confirmation page on the domain table (bulk delete action)
|
# Override for the delete confirmation page on the domain table (bulk delete action)
|
||||||
delete_selected_confirmation_template = "django/admin/domain_invitation_delete_selected_confirmation.html"
|
delete_selected_confirmation_template = "django/admin/domain_invitation_delete_selected_confirmation.html"
|
||||||
|
|
||||||
# Select domain invitations to change -> Domain invitations
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Domain invitations"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||||
"""Override the change_view to add the invitation obj for the change_form_object_tools template"""
|
"""Override the change_view to add the invitation obj for the change_form_object_tools template"""
|
||||||
|
|
||||||
|
@ -1673,14 +1682,6 @@ class PortfolioInvitationAdmin(BaseInvitationAdmin):
|
||||||
change_form_template = "django/admin/portfolio_invitation_change_form.html"
|
change_form_template = "django/admin/portfolio_invitation_change_form.html"
|
||||||
delete_confirmation_template = "django/admin/portfolio_invitation_delete_confirmation.html"
|
delete_confirmation_template = "django/admin/portfolio_invitation_delete_confirmation.html"
|
||||||
|
|
||||||
# Select portfolio invitations to change -> Portfolio invitations
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Portfolio invitations"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
"""
|
"""
|
||||||
Override the save_model method.
|
Override the save_model method.
|
||||||
|
@ -2070,14 +2071,6 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
readonly_fields.extend([field for field in self.analyst_readonly_fields])
|
readonly_fields.extend([field for field in self.analyst_readonly_fields])
|
||||||
return readonly_fields # Read-only fields for analysts
|
return readonly_fields # Read-only fields for analysts
|
||||||
|
|
||||||
# Select domain information to change -> Domain information
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Domain information"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||||
"""Customize the behavior of formfields with foreign key relationships. This will customize
|
"""Customize the behavior of formfields with foreign key relationships. This will customize
|
||||||
the behavior of selects. Customized behavior includes sorting of objects in list."""
|
the behavior of selects. Customized behavior includes sorting of objects in list."""
|
||||||
|
@ -2898,11 +2891,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
if next_char.isdigit():
|
if next_char.isdigit():
|
||||||
should_apply_default_filter = True
|
should_apply_default_filter = True
|
||||||
|
|
||||||
# Select domain request to change -> Domain requests
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Domain requests"
|
|
||||||
|
|
||||||
if should_apply_default_filter:
|
if should_apply_default_filter:
|
||||||
# modify the GET of the request to set the selected filter
|
# modify the GET of the request to set the selected filter
|
||||||
modified_get = copy.deepcopy(request.GET)
|
modified_get = copy.deepcopy(request.GET)
|
||||||
|
@ -3959,14 +3947,6 @@ class DraftDomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
# If no redirection is needed, return the original response
|
# If no redirection is needed, return the original response
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Select draft domain to change -> Draft domains
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "Draft domains"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class PublicContactResource(resources.ModelResource):
|
class PublicContactResource(resources.ModelResource):
|
||||||
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
"""defines how each field in the referenced model should be mapped to the corresponding fields in the
|
||||||
|
@ -4388,14 +4368,6 @@ class UserGroupAdmin(AuditedAdmin):
|
||||||
def user_group(self, obj):
|
def user_group(self, obj):
|
||||||
return obj.name
|
return obj.name
|
||||||
|
|
||||||
# Select user groups to change -> User groups
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["tabtitle"] = "User groups"
|
|
||||||
# Get the filtered values
|
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class WaffleFlagAdmin(FlagAdmin):
|
class WaffleFlagAdmin(FlagAdmin):
|
||||||
"""Custom admin implementation of django-waffle's Flag class"""
|
"""Custom admin implementation of django-waffle's Flag class"""
|
||||||
|
@ -4412,6 +4384,13 @@ class WaffleFlagAdmin(FlagAdmin):
|
||||||
if extra_context is None:
|
if extra_context is None:
|
||||||
extra_context = {}
|
extra_context = {}
|
||||||
extra_context["dns_prototype_flag"] = flag_is_active_for_user(request.user, "dns_prototype_flag")
|
extra_context["dns_prototype_flag"] = flag_is_active_for_user(request.user, "dns_prototype_flag")
|
||||||
|
|
||||||
|
# Loads "tabtitle" for this admin page so that on render the <title>
|
||||||
|
# element will only have the model name instead of
|
||||||
|
# the default string loaded by native Django admin code.
|
||||||
|
# (Eg. instead of "Select waffle flags to change", display "Waffle Flags")
|
||||||
|
# see "base_site.html" for the <title> code.
|
||||||
|
extra_context["tabtitle"] = str(self.opts.verbose_name_plural).title()
|
||||||
return super().changelist_view(request, extra_context=extra_context)
|
return super().changelist_view(request, extra_context=extra_context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Registrar Analytics | Django admin
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content_title %}<h1>Registrar Analytics</h1>{% endblock %}
|
{% block content_title %}<h1>Registrar Analytics</h1>{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
{{ tabtitle }} |
|
{{ tabtitle }} |
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ title }} |
|
{{ title }} |
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ site_title|default:_('Django site admin') }}
|
Django admin
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extrastyle %}{{ block.super }}
|
{% block extrastyle %}{{ block.super }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue