mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Revert "Fixed #24474 -- Allowed configuring the admin's empty change list value."
This reverts commit 72f769f494.
There are several test failures that need to be fixed.
This commit is contained in:
@@ -20,9 +20,9 @@ from .admin import (
|
||||
BandAdmin, ChildAdmin, ChordsBandAdmin, CustomPaginationAdmin,
|
||||
CustomPaginator, DynamicListDisplayChildAdmin,
|
||||
DynamicListDisplayLinksChildAdmin, DynamicListFilterChildAdmin,
|
||||
DynamicSearchFieldsChildAdmin, EmptyValueChildAdmin, FilteredChildAdmin,
|
||||
GroupAdmin, InvitationAdmin, NoListDisplayLinksParentAdmin, ParentAdmin,
|
||||
QuartetAdmin, SwallowAdmin, site as custom_site,
|
||||
DynamicSearchFieldsChildAdmin, FilteredChildAdmin, GroupAdmin,
|
||||
InvitationAdmin, NoListDisplayLinksParentAdmin, ParentAdmin, QuartetAdmin,
|
||||
SwallowAdmin, site as custom_site,
|
||||
)
|
||||
from .models import (
|
||||
Band, Child, ChordsBand, ChordsMusician, CustomIdUser, Event, Genre, Group,
|
||||
@@ -109,67 +109,14 @@ class ChangeListTests(TestCase):
|
||||
list_display = m.get_list_display(request)
|
||||
list_display_links = m.get_list_display_links(request, list_display)
|
||||
cl = ChangeList(request, Child, list_display, list_display_links,
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
cl.formset = None
|
||||
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
|
||||
context = Context({'cl': cl})
|
||||
table_output = template.render(context)
|
||||
link = reverse('admin:admin_changelist_child_change', args=(new_child.id,))
|
||||
row_html = (
|
||||
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
|
||||
'<td class="field-parent nowrap">-</td></tr></tbody>' % link
|
||||
)
|
||||
self.assertNotEqual(table_output.find(row_html), -1,
|
||||
'Failed to find expected row element: %s' % table_output)
|
||||
|
||||
def test_result_list_set_empty_value_display_on_admin_site(self):
|
||||
"""
|
||||
Test that empty value display can be set on AdminSite
|
||||
"""
|
||||
new_child = Child.objects.create(name='name', parent=None)
|
||||
request = self.factory.get('/child/')
|
||||
# Set a new empty display value on AdminSite.
|
||||
admin.site.empty_value_display = '???'
|
||||
m = ChildAdmin(Child, admin.site)
|
||||
list_display = m.get_list_display(request)
|
||||
list_display_links = m.get_list_display_links(request, list_display)
|
||||
cl = ChangeList(request, Child, list_display, list_display_links,
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
cl.formset = None
|
||||
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
|
||||
context = Context({'cl': cl})
|
||||
table_output = template.render(context)
|
||||
link = reverse('admin:admin_changelist_child_change', args=(new_child.id,))
|
||||
row_html = (
|
||||
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
|
||||
'<td class="field-parent nowrap">???</td></tr></tbody>' % link
|
||||
)
|
||||
self.assertNotEqual(table_output.find(row_html), -1,
|
||||
'Failed to find expected row element: %s' % table_output)
|
||||
|
||||
def test_result_list_set_empty_value_display_in_model_admin(self):
|
||||
"""
|
||||
Test that empty value display can be set in ModelAdmin or individual fields.
|
||||
"""
|
||||
new_child = Child.objects.create(name='name', parent=None)
|
||||
request = self.factory.get('/child/')
|
||||
m = EmptyValueChildAdmin(Child, admin.site)
|
||||
list_display = m.get_list_display(request)
|
||||
list_display_links = m.get_list_display_links(request, list_display)
|
||||
cl = ChangeList(request, Child, list_display, list_display_links,
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
cl.formset = None
|
||||
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
|
||||
context = Context({'cl': cl})
|
||||
table_output = template.render(context)
|
||||
link = reverse('admin:admin_changelist_child_change', args=(new_child.id,))
|
||||
row_html = (
|
||||
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
|
||||
'<td class="field-age_display">†</td><td class="field-age">-empty-</td></tr></tbody>' % link
|
||||
)
|
||||
row_html = '<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th><td class="field-parent nowrap">-</td></tr></tbody>' % link
|
||||
self.assertNotEqual(table_output.find(row_html), -1,
|
||||
'Failed to find expected row element: %s' % table_output)
|
||||
|
||||
@@ -185,17 +132,14 @@ class ChangeListTests(TestCase):
|
||||
list_display = m.get_list_display(request)
|
||||
list_display_links = m.get_list_display_links(request, list_display)
|
||||
cl = ChangeList(request, Child, list_display, list_display_links,
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
m.list_filter, m.date_hierarchy, m.search_fields,
|
||||
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)
|
||||
cl.formset = None
|
||||
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
|
||||
context = Context({'cl': cl})
|
||||
table_output = template.render(context)
|
||||
link = reverse('admin:admin_changelist_child_change', args=(new_child.id,))
|
||||
row_html = (
|
||||
'<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th>'
|
||||
'<td class="field-parent nowrap">Parent object</td></tr></tbody>' % link
|
||||
)
|
||||
row_html = '<tbody><tr class="row1"><th class="field-name"><a href="%s">name</a></th><td class="field-parent nowrap">Parent object</td></tr></tbody>' % link
|
||||
self.assertNotEqual(table_output.find(row_html), -1,
|
||||
'Failed to find expected row element: %s' % table_output)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user