Fixed #15971 -- Fixed regression introduced in r16144 that prevented the use of the field's verbose_name attribute. Thanks to mk and Julien.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4d039d8d05
commit
032b4ab5df
|
@ -110,7 +110,7 @@ class FieldListFilter(ListFilter):
|
||||||
def __init__(self, field, request, params, model, model_admin, field_path):
|
def __init__(self, field, request, params, model, model_admin, field_path):
|
||||||
self.field = field
|
self.field = field
|
||||||
self.field_path = field_path
|
self.field_path = field_path
|
||||||
self.title = field_path
|
self.title = getattr(field, 'verbose_name', field_path)
|
||||||
super(FieldListFilter, self).__init__(request, params, model, model_admin)
|
super(FieldListFilter, self).__init__(request, params, model, model_admin)
|
||||||
|
|
||||||
def has_output(self):
|
def has_output(self):
|
||||||
|
|
|
@ -128,7 +128,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][4]
|
filterspec = changelist.get_filters(request)[0][4]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'date_registered')
|
self.assertEqual(force_unicode(filterspec.title), u'date registered')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "Today")
|
choice = select_by(filterspec.choices(changelist), "display", "Today")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?date_registered__day=%s'
|
self.assertEqual(choice['query_string'], '?date_registered__day=%s'
|
||||||
|
@ -150,7 +150,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][4]
|
filterspec = changelist.get_filters(request)[0][4]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'date_registered')
|
self.assertEqual(force_unicode(filterspec.title), u'date registered')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "This month")
|
choice = select_by(filterspec.choices(changelist), "display", "This month")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?date_registered__month=%s'
|
self.assertEqual(choice['query_string'], '?date_registered__month=%s'
|
||||||
|
@ -170,7 +170,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][4]
|
filterspec = changelist.get_filters(request)[0][4]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'date_registered')
|
self.assertEqual(force_unicode(filterspec.title), u'date registered')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "This year")
|
choice = select_by(filterspec.choices(changelist), "display", "This year")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?date_registered__year=%s'
|
self.assertEqual(choice['query_string'], '?date_registered__year=%s'
|
||||||
|
@ -186,7 +186,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][4]
|
filterspec = changelist.get_filters(request)[0][4]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'date_registered')
|
self.assertEqual(force_unicode(filterspec.title), u'date registered')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "Past 7 days")
|
choice = select_by(filterspec.choices(changelist), "display", "Past 7 days")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
|
self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
|
||||||
|
@ -349,7 +349,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][3]
|
filterspec = changelist.get_filters(request)[0][3]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
|
self.assertEqual(force_unicode(filterspec.title), u'is best seller')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "No")
|
choice = select_by(filterspec.choices(changelist), "display", "No")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?is_best_seller__exact=0')
|
self.assertEqual(choice['query_string'], '?is_best_seller__exact=0')
|
||||||
|
@ -363,7 +363,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][3]
|
filterspec = changelist.get_filters(request)[0][3]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
|
self.assertEqual(force_unicode(filterspec.title), u'is best seller')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "Yes")
|
choice = select_by(filterspec.choices(changelist), "display", "Yes")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?is_best_seller__exact=1')
|
self.assertEqual(choice['query_string'], '?is_best_seller__exact=1')
|
||||||
|
@ -377,7 +377,7 @@ class ListFiltersTests(TestCase):
|
||||||
|
|
||||||
# Make sure the correct choice is selected
|
# Make sure the correct choice is selected
|
||||||
filterspec = changelist.get_filters(request)[0][3]
|
filterspec = changelist.get_filters(request)[0][3]
|
||||||
self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
|
self.assertEqual(force_unicode(filterspec.title), u'is best seller')
|
||||||
choice = select_by(filterspec.choices(changelist), "display", "Unknown")
|
choice = select_by(filterspec.choices(changelist), "display", "Unknown")
|
||||||
self.assertEqual(choice['selected'], True)
|
self.assertEqual(choice['selected'], True)
|
||||||
self.assertEqual(choice['query_string'], '?is_best_seller__isnull=True')
|
self.assertEqual(choice['query_string'], '?is_best_seller__isnull=True')
|
||||||
|
|
Loading…
Reference in New Issue