Fixed #27888 -- Added link to clear all filters in the admin changelist view.
This commit is contained in:
parent
5a68a223c7
commit
b94764e178
|
@ -187,6 +187,12 @@
|
||||||
color: #036;
|
color: #036;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#changelist-filter #changelist-filter-clear a {
|
||||||
|
font-size: 13px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
}
|
||||||
|
|
||||||
/* DATE DRILLDOWN */
|
/* DATE DRILLDOWN */
|
||||||
|
|
||||||
.change-list ul.toplinks {
|
.change-list ul.toplinks {
|
||||||
|
|
|
@ -60,6 +60,11 @@
|
||||||
{% if cl.has_filters %}
|
{% if cl.has_filters %}
|
||||||
<div id="changelist-filter">
|
<div id="changelist-filter">
|
||||||
<h2>{% translate 'Filter' %}</h2>
|
<h2>{% translate 'Filter' %}</h2>
|
||||||
|
{% if cl.has_filters or cl.search_fields %}
|
||||||
|
{% if cl.preserved_filters %}<h3 id="changelist-filter-clear">
|
||||||
|
<a href="?{% if cl.is_popup %}_popup=1{% endif %}">✖ {% translate "Clear all filters" %}</a>
|
||||||
|
</h3>{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
|
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -37,6 +37,9 @@ Minor features
|
||||||
:attr:`.ModelAdmin.list_filter` allows filtering on empty values (empty
|
:attr:`.ModelAdmin.list_filter` allows filtering on empty values (empty
|
||||||
strings and nulls) in the admin changelist view.
|
strings and nulls) in the admin changelist view.
|
||||||
|
|
||||||
|
* Filters in the right sidebar of the admin changelist view now contains a link
|
||||||
|
to clear all filters.
|
||||||
|
|
||||||
:mod:`django.contrib.admindocs`
|
:mod:`django.contrib.admindocs`
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -707,6 +707,18 @@ class ChangeListTests(TestCase):
|
||||||
link = reverse('admin:admin_changelist_parent_change', args=(p.pk,))
|
link = reverse('admin:admin_changelist_parent_change', args=(p.pk,))
|
||||||
self.assertNotContains(response, '<a href="%s">' % link)
|
self.assertNotContains(response, '<a href="%s">' % link)
|
||||||
|
|
||||||
|
def test_clear_all_filters_link(self):
|
||||||
|
self.client.force_login(self.superuser)
|
||||||
|
link = '<a href="?">✖ Clear all filters</a>'
|
||||||
|
response = self.client.get(reverse('admin:auth_user_changelist'))
|
||||||
|
self.assertNotContains(response, link)
|
||||||
|
for data in (
|
||||||
|
{SEARCH_VAR: 'test'},
|
||||||
|
{'is_staff__exact': '0'},
|
||||||
|
):
|
||||||
|
response = self.client.get(reverse('admin:auth_user_changelist'), data=data)
|
||||||
|
self.assertContains(response, link)
|
||||||
|
|
||||||
def test_tuple_list_display(self):
|
def test_tuple_list_display(self):
|
||||||
swallow = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2')
|
swallow = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2')
|
||||||
swallow2 = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2')
|
swallow2 = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2')
|
||||||
|
|
Loading…
Reference in New Issue