From 872b61193b013a700ff88cf50f0eb2cf2c266ff7 Mon Sep 17 00:00:00 2001 From: Florian Perucki Date: Sat, 24 Sep 2022 17:47:41 +0200 Subject: [PATCH] Refs #34041 -- Added navigation landmark to breadcrumbs in admin. Thanks Thibaud Colas for pair programming. --- .../contrib/admin/templates/admin/base.html | 14 +++++++---- .../contrib/admin/templates/admin/index.html | 2 +- .../contrib/admin/templates/admin/login.html | 2 +- docs/releases/4.2.txt | 3 +++ tests/admin_views/test_breadcrumbs.py | 25 +++++++++++++++++++ 5 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 tests/admin_views/test_breadcrumbs.py diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index b9811a0bdb..5d90bea54e 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -69,11 +69,15 @@ {% endblock %} - {% block breadcrumbs %} - + {% block nav-breadcrumbs %} + {% endblock %} {% endif %} diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html index 5674264093..af4f26dec5 100644 --- a/django/contrib/admin/templates/admin/index.html +++ b/django/contrib/admin/templates/admin/index.html @@ -7,7 +7,7 @@ {% block bodyclass %}{{ block.super }} dashboard{% endblock %} -{% block breadcrumbs %}{% endblock %} +{% block nav-breadcrumbs %}{% endblock %} {% block nav-sidebar %}{% endblock %} diff --git a/django/contrib/admin/templates/admin/login.html b/django/contrib/admin/templates/admin/login.html index a14e91c5d7..b61d9ec603 100644 --- a/django/contrib/admin/templates/admin/login.html +++ b/django/contrib/admin/templates/admin/login.html @@ -15,7 +15,7 @@ {% block content_title %}{% endblock %} -{% block breadcrumbs %}{% endblock %} +{% block nav-breadcrumbs %}{% endblock %} {% block content %} {% if form.errors and not form.non_field_errors %} diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 7ca4f0271e..80c0d97bfc 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -48,6 +48,9 @@ Minor features :attr:`~django.contrib.admin.ModelAdmin.filter_vertical` widgets are now filterable. +* The ``admin/base.html`` template now has a new block ``nav-breadcrumbs`` + which contains the navigation landmark and the ``breadcrumbs`` block. + :mod:`django.contrib.admindocs` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/admin_views/test_breadcrumbs.py b/tests/admin_views/test_breadcrumbs.py new file mode 100644 index 0000000000..ee4285f9a9 --- /dev/null +++ b/tests/admin_views/test_breadcrumbs.py @@ -0,0 +1,25 @@ +from django.contrib.auth.models import User +from django.test import TestCase, override_settings +from django.urls import reverse + + +@override_settings(ROOT_URLCONF="admin_views.urls") +class AdminBreadcrumbsTests(TestCase): + @classmethod + def setUpTestData(cls): + cls.superuser = User.objects.create_superuser( + username="super", + password="secret", + email="super@example.com", + ) + + def setUp(self): + self.client.force_login(self.superuser) + + def test_breadcrumbs_absent(self): + response = self.client.get(reverse("admin:index")) + self.assertNotContains(response, '