mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #17252 -- Fixed a minor regression introduced by the work in #11868, where the default sorted columns wouldn't correctly be visually represented in the changelist table headers if those columns referred to non model fields. Thanks to sebastian for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17143 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -37,7 +37,8 @@ from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
|
||||
DooHickey, FancyDoodad, Whatsit, Category, Post, Plot, FunkyTag, Chapter,
|
||||
Book, Promo, WorkHour, Employee, Question, Answer, Inquisition, Actor,
|
||||
FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story,
|
||||
OtherStory, ComplexSortedPerson, Parent, Child)
|
||||
OtherStory, ComplexSortedPerson, Parent, Child, AdminOrderedField,
|
||||
AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable)
|
||||
|
||||
|
||||
ERROR_MESSAGE = "Please enter the correct username and password \
|
||||
@@ -354,6 +355,32 @@ class AdminViewBasicTest(TestCase):
|
||||
response.content.index(link % p2.id) < response.content.index(link % p1.id)
|
||||
)
|
||||
|
||||
def testSortIndicatorsAdminOrder(self):
|
||||
"""
|
||||
Ensures that the admin shows default sort indicators for all
|
||||
kinds of 'ordering' fields: field names, method on the model
|
||||
admin and model itself, and other callables. See #17252.
|
||||
"""
|
||||
models = [(AdminOrderedField, 'adminorderedfield' ),
|
||||
(AdminOrderedModelMethod, 'adminorderedmodelmethod'),
|
||||
(AdminOrderedAdminMethod, 'adminorderedadminmethod'),
|
||||
(AdminOrderedCallable, 'adminorderedcallable' )]
|
||||
for model, url in models:
|
||||
a1 = model.objects.create(stuff='The Last Item', order=3)
|
||||
a2 = model.objects.create(stuff='The First Item', order=1)
|
||||
a3 = model.objects.create(stuff='The Middle Item', order=2)
|
||||
response = self.client.get('/test_admin/admin/admin_views/%s/' % url, {})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# Should have 3 columns including action checkbox col.
|
||||
self.assertContains(response, '<th scope="col"', count=3, msg_prefix=url)
|
||||
# Check if the correct column was selected. 2 is the index of the
|
||||
# 'order' column in the model admin's 'list_display' with 0 being
|
||||
# the implicit 'action_checkbox' and 1 being the column 'stuff'.
|
||||
self.assertEqual(response.context['cl'].get_ordering_field_columns(), {2: 'asc'})
|
||||
# Check order of records.
|
||||
self.assertTrue(response.content.index('The First Item') <
|
||||
response.content.index('The Middle Item') < response.content.index('The Last Item'))
|
||||
|
||||
def testLimitedFilter(self):
|
||||
"""Ensure admin changelist filters do not contain objects excluded via limit_choices_to.
|
||||
This also tests relation-spanning filters (e.g. 'color__value').
|
||||
@@ -2757,7 +2784,7 @@ class PrePopulatedTest(TestCase):
|
||||
self.assertNotContains(response, "id: '#id_slug'")
|
||||
self.assertNotContains(response, "field['dependency_ids'].push('#id_title');")
|
||||
self.assertNotContains(response, "id: '#id_prepopulatedsubpost_set-0-subslug',")
|
||||
|
||||
|
||||
@override_settings(USE_THOUSAND_SEPARATOR = True, USE_L10N = True)
|
||||
def test_prepopulated_maxlength_localized(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user