Fixed #27386 -- Wrapped admin's readonly fields in <div> rather than <p>.
This commit is contained in:
parent
a17fe73d2d
commit
b3162cab94
|
@ -83,7 +83,7 @@ form ul.inline li {
|
|||
height: 26px;
|
||||
}
|
||||
|
||||
.aligned label + p, .aligned label + div.help {
|
||||
.aligned label + p, .aligned label + div.help, .aligned label + div.readonly {
|
||||
padding: 6px 0;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% else %}
|
||||
{{ field.label_tag }}
|
||||
{% if field.is_readonly %}
|
||||
<p>{{ field.contents }}</p>
|
||||
<div class="readonly">{{ field.contents }}</div>
|
||||
{% else %}
|
||||
{{ field.field }}
|
||||
{% endif %}
|
||||
|
|
|
@ -501,6 +501,15 @@ This works similar to ``settings.TIME_ZONE = None`` except that it also sets
|
|||
if there's a use case where you find you can't adapt your code to set a
|
||||
``TIME_ZONE``.
|
||||
|
||||
HTML changes in admin templates
|
||||
-------------------------------
|
||||
|
||||
``<p class="help">`` is replaced with a ``<div>`` tag to allow including lists
|
||||
inside help text.
|
||||
|
||||
Read-only fields are wrapped in ``<div class="readonly">...</div>`` instead of
|
||||
``<p>...</p>`` to allow any kind of HTML as the field's content.
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
|
|
|
@ -4598,11 +4598,15 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
|||
self.assertContains(response, "foo")
|
||||
|
||||
# Multiline text in a readonly field gets <br /> tags
|
||||
self.assertContains(response, "Multiline<br />test<br />string")
|
||||
self.assertContains(response, "<p>Multiline<br />html<br />content</p>", html=True)
|
||||
self.assertContains(response, "InlineMultiline<br />test<br />string")
|
||||
self.assertContains(response, 'Multiline<br />test<br />string')
|
||||
self.assertContains(response, '<div class="readonly">Multiline<br />html<br />content</div>', html=True)
|
||||
self.assertContains(response, 'InlineMultiline<br />test<br />string')
|
||||
# Remove only this last line when the deprecation completes.
|
||||
self.assertContains(response, "<p>Multiline<br />html<br />content<br />with allow tags</p>", html=True)
|
||||
self.assertContains(
|
||||
response,
|
||||
'<div class="readonly">Multiline<br />html<br />content<br />with allow tags</div>',
|
||||
html=True
|
||||
)
|
||||
|
||||
self.assertContains(response, formats.localize(datetime.date.today() - datetime.timedelta(days=7)))
|
||||
|
||||
|
@ -4685,8 +4689,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
|||
"""
|
||||
choice = Choice.objects.create(choice=None)
|
||||
response = self.client.get(reverse('admin:admin_views_choice_change', args=(choice.pk,)))
|
||||
self.assertContains(response, '<p>No opinion</p>', html=True)
|
||||
self.assertNotContains(response, '<p>(None)</p>')
|
||||
self.assertContains(response, '<div class="readonly">No opinion</div>', html=True)
|
||||
|
||||
def test_readonly_manytomany_backwards_ref(self):
|
||||
"""
|
||||
|
@ -4705,7 +4708,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
|||
pizza.toppings.add(topping)
|
||||
response = self.client.get(reverse('admin:admin_views_pizza_change', args=(pizza.pk,)))
|
||||
self.assertContains(response, '<label>Toppings:</label>', html=True)
|
||||
self.assertContains(response, '<p>Salami</p>', html=True)
|
||||
self.assertContains(response, '<div class="readonly">Salami</div>', html=True)
|
||||
|
||||
def test_readonly_onetoone_backwards_ref(self):
|
||||
"""
|
||||
|
|
|
@ -419,8 +419,8 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
|
|||
response = self.client.get(reverse('admin:admin_widgets_album_change', args=(self.album.id,)))
|
||||
self.assertContains(
|
||||
response,
|
||||
'<p><a href="%(STORAGE_URL)salbums/hybrid_theory.jpg">'
|
||||
r'albums\hybrid_theory.jpg</a></p>' % {'STORAGE_URL': default_storage.url('')},
|
||||
'<div class="readonly"><a href="%(STORAGE_URL)salbums/hybrid_theory.jpg">'
|
||||
r'albums\hybrid_theory.jpg</a></div>' % {'STORAGE_URL': default_storage.url('')},
|
||||
html=True,
|
||||
)
|
||||
self.assertNotContains(
|
||||
|
@ -431,7 +431,7 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
|
|||
response = self.client.get(reverse('admin:admin_widgets_album_add'))
|
||||
self.assertContains(
|
||||
response,
|
||||
'<p></p>',
|
||||
'<div class="readonly"></div>',
|
||||
html=True,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue