mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #9969: choices with options groups (added in [7977]) now work correctly in the admin with list_display and list_filter. Thanks, ramiro.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10318 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -21,7 +21,7 @@ except NameError:
|
||||
from sets import Set as set
|
||||
|
||||
class AdminViewBasicTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml']
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml']
|
||||
|
||||
# Store the bit of the URL where the admin is registered as a class
|
||||
# variable. That way we can test a second AdminSite just by subclassing
|
||||
@@ -182,6 +182,37 @@ class AdminViewBasicTest(TestCase):
|
||||
response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'color__id__exact': 'StringNotInteger!'})
|
||||
self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit)
|
||||
|
||||
def testNamedGroupFieldChoicesChangeList(self):
|
||||
"""
|
||||
Ensures the admin changelist shows correct values in the relevant column
|
||||
for rows corresponding to instances of a model in which a named group
|
||||
has been used in the choices option of a field.
|
||||
"""
|
||||
response = self.client.get('/test_admin/%s/admin_views/fabric/' % self.urlbit)
|
||||
self.failUnlessEqual(response.status_code, 200)
|
||||
self.failUnless(
|
||||
'<a href="1/">Horizontal</a>' in response.content and
|
||||
'<a href="2/">Vertical</a>' in response.content,
|
||||
"Changelist table isn't showing the right human-readable values set by a model field 'choices' option named group."
|
||||
)
|
||||
|
||||
def testNamedGroupFieldChoicesFilter(self):
|
||||
"""
|
||||
Ensures the filter UI shows correctly when at least one named group has
|
||||
been used in the choices option of a model field.
|
||||
"""
|
||||
response = self.client.get('/test_admin/%s/admin_views/fabric/' % self.urlbit)
|
||||
self.failUnlessEqual(response.status_code, 200)
|
||||
self.failUnless(
|
||||
'<div id="changelist-filter">' in response.content,
|
||||
"Expected filter not found in changelist view."
|
||||
)
|
||||
self.failUnless(
|
||||
'<a href="?surface__exact=x">Horizontal</a>' in response.content and
|
||||
'<a href="?surface__exact=y">Vertical</a>' in response.content,
|
||||
"Changelist filter isn't showing options contained inside a model field 'choices' option named group."
|
||||
)
|
||||
|
||||
class CustomModelAdminTest(AdminViewBasicTest):
|
||||
urlbit = "admin2"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user