mirror of https://github.com/django/django.git
Refs #34041 -- Added navigation landmark to breadcrumbs in admin.
Thanks Thibaud Colas for pair programming.
This commit is contained in:
parent
fe6f4bef03
commit
872b61193b
|
@ -69,11 +69,15 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<!-- END Header -->
|
<!-- END Header -->
|
||||||
{% block breadcrumbs %}
|
{% block nav-breadcrumbs %}
|
||||||
<div class="breadcrumbs">
|
<nav aria-label="{% translate 'Breadcrumbs' %}">
|
||||||
<a href="{% url 'admin:index' %}">{% translate 'Home' %}</a>
|
{% block breadcrumbs %}
|
||||||
{% if title %} › {{ title }}{% endif %}
|
<div class="breadcrumbs">
|
||||||
</div>
|
<a href="{% url 'admin:index' %}">{% translate 'Home' %}</a>
|
||||||
|
{% if title %} › {{ title }}{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
|
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}{% endblock %}
|
{% block nav-breadcrumbs %}{% endblock %}
|
||||||
|
|
||||||
{% block nav-sidebar %}{% endblock %}
|
{% block nav-sidebar %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% block content_title %}{% endblock %}
|
{% block content_title %}{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}{% endblock %}
|
{% block nav-breadcrumbs %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if form.errors and not form.non_field_errors %}
|
{% if form.errors and not form.non_field_errors %}
|
||||||
|
|
|
@ -48,6 +48,9 @@ Minor features
|
||||||
:attr:`~django.contrib.admin.ModelAdmin.filter_vertical` widgets are now
|
:attr:`~django.contrib.admin.ModelAdmin.filter_vertical` widgets are now
|
||||||
filterable.
|
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`
|
:mod:`django.contrib.admindocs`
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -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, '<nav aria-label="Breadcrumbs">')
|
||||||
|
|
||||||
|
def test_breadcrumbs_present(self):
|
||||||
|
response = self.client.get(reverse("admin:auth_user_add"))
|
||||||
|
self.assertContains(response, '<nav aria-label="Breadcrumbs">')
|
Loading…
Reference in New Issue