Fixed #21371 -- Added the block.super to admin bodyclass blocks.
Thanks Keryn Knight for the report.
This commit is contained in:
parent
59d9b26474
commit
f5123c7291
|
@ -1,7 +1,7 @@
|
||||||
{% extends "admin/index.html" %}
|
{% extends "admin/index.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block bodyclass %}app-{{ app_label }} {{ block.super }}{% endblock %}
|
{% block bodyclass %}{{ block.super }} app-{{ app_label }}{% endblock %}
|
||||||
|
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
|
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
|
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
|
||||||
{% block bodyclass %}{{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %}
|
{% block bodyclass %}{{ block.super }} {{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %}
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<div class="breadcrumbs">
|
<div class="breadcrumbs">
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
{% block coltype %}colM{% endblock %}
|
{% block coltype %}colM{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}
|
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}
|
||||||
|
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
{% endif %}{% endif %}
|
{% endif %}{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}
|
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}
|
||||||
|
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "admin/base_site.html" %}
|
{% extends "admin/base_site.html" %}
|
||||||
{% load i18n admin_urls %}
|
{% load i18n admin_urls %}
|
||||||
|
|
||||||
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %}
|
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<div class="breadcrumbs">
|
<div class="breadcrumbs">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "admin/base_site.html" %}
|
{% extends "admin/base_site.html" %}
|
||||||
{% load i18n l10n admin_urls %}
|
{% load i18n l10n admin_urls %}
|
||||||
|
|
||||||
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %}
|
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<div class="breadcrumbs">
|
<div class="breadcrumbs">
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block coltype %}colMS{% endblock %}
|
{% block coltype %}colMS{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}dashboard{% endblock %}
|
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}{% endblock %}
|
{% block breadcrumbs %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
|
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}login{% endblock %}
|
{% block bodyclass %}{{ block.super }} login{% endblock %}
|
||||||
|
|
||||||
{% block nav-global %}{% endblock %}
|
{% block nav-global %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "admin/base.html" %}
|
||||||
|
|
||||||
|
{% block bodyclass%}bodyclass_consistency_check{% endblock %}
|
|
@ -58,6 +58,7 @@ from .admin import site, site2, CityAdmin
|
||||||
|
|
||||||
ERROR_MESSAGE = "Please enter the correct username and password \
|
ERROR_MESSAGE = "Please enter the correct username and password \
|
||||||
for a staff account. Note that both fields may be case-sensitive."
|
for a staff account. Note that both fields may be case-sensitive."
|
||||||
|
ADMIN_VIEW_TEMPLATES_DIR = settings.TEMPLATE_DIRS + (os.path.join(os.path.dirname(upath(__file__)), 'templates'),)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||||
|
@ -648,6 +649,83 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||||
reverse('admin:app_list', args=('admin_views2',))
|
reverse('admin:app_list', args=('admin_views2',))
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(TEMPLATE_DIRS=ADMIN_VIEW_TEMPLATES_DIR)
|
||||||
|
class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||||
|
def test_extended_bodyclass_template_change_form(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/change_form.html template uses block.super in the
|
||||||
|
bodyclass block.
|
||||||
|
"""
|
||||||
|
response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit)
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_template_change_password(self):
|
||||||
|
"""
|
||||||
|
Ensure that the auth/user/change_password.html template uses block
|
||||||
|
super in the bodyclass block.
|
||||||
|
"""
|
||||||
|
user = User.objects.get(username='super')
|
||||||
|
response = self.client.get('/test_admin/%s/auth/user/%s/password/' % (self.urlbit, user.id))
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_template_index(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/index.html template uses block.super in the
|
||||||
|
bodyclass block.
|
||||||
|
"""
|
||||||
|
response = self.client.get('/test_admin/%s/' % self.urlbit)
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_change_list(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/change_list.html' template uses block.super
|
||||||
|
in the bodyclass block.
|
||||||
|
"""
|
||||||
|
response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit)
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_template_login(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/login.html template uses block.super in the
|
||||||
|
bodyclass block.
|
||||||
|
"""
|
||||||
|
self.client.logout()
|
||||||
|
response = self.client.get('/test_admin/%s/login/' % self.urlbit)
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_template_delete_confirmation(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/delete_confirmation.html template uses
|
||||||
|
block.super in the bodyclass block.
|
||||||
|
"""
|
||||||
|
group = Group.objects.create(name="foogroup")
|
||||||
|
response = self.client.get('/test_admin/%s/auth/group/%s/delete/' % (self.urlbit, group.id))
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_extended_bodyclass_template_delete_selected_confirmation(self):
|
||||||
|
"""
|
||||||
|
Ensure that the admin/delete_selected_confirmation.html template uses
|
||||||
|
block.super in bodyclass block.
|
||||||
|
"""
|
||||||
|
group = Group.objects.create(name="foogroup")
|
||||||
|
post_data = {
|
||||||
|
'action': 'delete_selected',
|
||||||
|
'selected_accross': '0',
|
||||||
|
'index': '0',
|
||||||
|
'_selected_action': group.id
|
||||||
|
}
|
||||||
|
response = self.client.post('/test_admin/%s/auth/group/' % (self.urlbit), post_data)
|
||||||
|
self.assertContains(response, 'bodyclass_consistency_check ')
|
||||||
|
|
||||||
|
def test_filter_with_custom_template(self):
|
||||||
|
"""
|
||||||
|
Ensure that one can use a custom template to render an admin filter.
|
||||||
|
Refs #17515.
|
||||||
|
"""
|
||||||
|
response = self.client.get("/test_admin/admin/admin_views/color2/")
|
||||||
|
self.assertTemplateUsed(response, 'custom_filter_template.html')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminViewFormUrlTest(TestCase):
|
class AdminViewFormUrlTest(TestCase):
|
||||||
urls = "admin_views.urls"
|
urls = "admin_views.urls"
|
||||||
|
@ -668,17 +746,6 @@ class AdminViewFormUrlTest(TestCase):
|
||||||
self.assertTrue('form_url' in response.context, msg='form_url not present in response.context')
|
self.assertTrue('form_url' in response.context, msg='form_url not present in response.context')
|
||||||
self.assertEqual(response.context['form_url'], 'pony')
|
self.assertEqual(response.context['form_url'], 'pony')
|
||||||
|
|
||||||
def test_filter_with_custom_template(self):
|
|
||||||
"""
|
|
||||||
Ensure that one can use a custom template to render an admin filter.
|
|
||||||
Refs #17515.
|
|
||||||
"""
|
|
||||||
template_dirs = settings.TEMPLATE_DIRS + (
|
|
||||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),)
|
|
||||||
with self.settings(TEMPLATE_DIRS=template_dirs):
|
|
||||||
response = self.client.get("/test_admin/admin/admin_views/color2/")
|
|
||||||
self.assertTemplateUsed(response, 'custom_filter_template.html')
|
|
||||||
|
|
||||||
|
|
||||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||||
class AdminJavaScriptTest(TestCase):
|
class AdminJavaScriptTest(TestCase):
|
||||||
|
@ -3874,7 +3941,7 @@ class CSSTest(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/admin_views/section/add/')
|
response = self.client.get('/test_admin/admin/admin_views/section/add/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<body class="app-admin_views model-section ')
|
'<body class=" app-admin_views model-section ')
|
||||||
|
|
||||||
def testAppModelInListBodyClass(self):
|
def testAppModelInListBodyClass(self):
|
||||||
"""
|
"""
|
||||||
|
@ -3883,7 +3950,7 @@ class CSSTest(TestCase):
|
||||||
response = self.client.get('/test_admin/admin/admin_views/section/')
|
response = self.client.get('/test_admin/admin/admin_views/section/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<body class="app-admin_views model-section ')
|
'<body class=" app-admin_views model-section ')
|
||||||
|
|
||||||
def testAppModelInDeleteConfirmationBodyClass(self):
|
def testAppModelInDeleteConfirmationBodyClass(self):
|
||||||
"""
|
"""
|
||||||
|
@ -3894,7 +3961,7 @@ class CSSTest(TestCase):
|
||||||
'/test_admin/admin/admin_views/section/1/delete/')
|
'/test_admin/admin/admin_views/section/1/delete/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<body class="app-admin_views model-section ')
|
'<body class=" app-admin_views model-section ')
|
||||||
|
|
||||||
def testAppModelInAppIndexBodyClass(self):
|
def testAppModelInAppIndexBodyClass(self):
|
||||||
"""
|
"""
|
||||||
|
@ -3902,7 +3969,7 @@ class CSSTest(TestCase):
|
||||||
"""
|
"""
|
||||||
response = self.client.get('/test_admin/admin/admin_views/')
|
response = self.client.get('/test_admin/admin/admin_views/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, '<body class="app-admin_views ')
|
self.assertContains(response, '<body class=" dashboard app-admin_views')
|
||||||
|
|
||||||
def testAppModelInDeleteSelectedConfirmationBodyClass(self):
|
def testAppModelInDeleteSelectedConfirmationBodyClass(self):
|
||||||
"""
|
"""
|
||||||
|
@ -3918,7 +3985,7 @@ class CSSTest(TestCase):
|
||||||
action_data)
|
action_data)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<body class="app-admin_views model-section ')
|
'<body class=" app-admin_views model-section ')
|
||||||
|
|
||||||
def test_changelist_field_classes(self):
|
def test_changelist_field_classes(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue