diff options
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/contrib/admin/sites.py | 1 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/app_index.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/change_form.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/change_list.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/delete_confirmation.html | 2 | ||||
| -rw-r--r-- | django/contrib/admin/templates/admin/delete_selected_confirmation.html | 2 | ||||
| -rw-r--r-- | docs/releases/1.6.txt | 4 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 53 |
9 files changed, 67 insertions, 2 deletions
@@ -544,6 +544,7 @@ answer newbie questions, and generally made Django that much better: George Song <george@damacy.net> sopel Leo Soto <leo.soto@gmail.com> + Thomas Sorrel Wiliam Alves de Souza <wiliamsouza83@gmail.com> Don Spaulding <donspauldingii@gmail.com> Calvin Spealman <ironfroggy@gmail.com> diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index e0f43dfbfe..8abf49331b 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -439,6 +439,7 @@ class AdminSite(object): context = { 'title': _('%s administration') % capfirst(app_label), 'app_list': [app_dict], + 'app_label': app_label, } context.update(extra_context or {}) diff --git a/django/contrib/admin/templates/admin/app_index.html b/django/contrib/admin/templates/admin/app_index.html index 9f65357292..7aff935126 100644 --- a/django/contrib/admin/templates/admin/app_index.html +++ b/django/contrib/admin/templates/admin/app_index.html @@ -1,6 +1,8 @@ {% extends "admin/index.html" %} {% load i18n %} +{% block bodyclass %}app-{{ app_label }} {{ block.super }}{% endblock %} + {% if not is_popup %} {% block breadcrumbs %} <div class="breadcrumbs"> diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index d4935ed781..e35c7328f4 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.html @@ -10,7 +10,7 @@ {% block coltype %}colM{% endblock %} -{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} +{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} change-form{% endblock %} {% if not is_popup %} {% block breadcrumbs %} diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html index 15583d1a8c..ce5c5b37a4 100644 --- a/django/contrib/admin/templates/admin/change_list.html +++ b/django/contrib/admin/templates/admin/change_list.html @@ -32,7 +32,7 @@ {% endif %}{% endif %} {% endblock %} -{% block bodyclass %}change-list{% endblock %} +{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} change-list{% endblock %} {% if not is_popup %} {% block breadcrumbs %} diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html index 3ed60807b7..2e94b61485 100644 --- a/django/contrib/admin/templates/admin/delete_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_confirmation.html @@ -1,6 +1,8 @@ {% extends "admin/base_site.html" %} {% load i18n admin_urls %} +{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} delete-confirmation{% endblock %} + {% block breadcrumbs %} <div class="breadcrumbs"> <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html index 36527dcbf5..a80f4e4a54 100644 --- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html @@ -1,6 +1,8 @@ {% extends "admin/base_site.html" %} {% load i18n l10n admin_urls %} +{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} delete-confirmation delete-selected-confirmation{% endblock %} + {% block breadcrumbs %} <div class="breadcrumbs"> <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt index 1419f0915c..b8babe1843 100644 --- a/docs/releases/1.6.txt +++ b/docs/releases/1.6.txt @@ -199,6 +199,10 @@ Minor features * The admin list columns have a ``column-<field_name>`` class in the HTML so the columns header can be styled with CSS, e.g. to set a column width. +* Some admin templates now have ``app-<app_name>`` and ``model-<model_name>`` + classes in their ``<body>`` tag to allow customizing the CSS per app or per + model. + * The :ref:`isolation level<database-isolation-level>` can be customized under PostgreSQL. diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index a83c756a25..7decf6f471 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -3824,6 +3824,59 @@ class CSSTest(TestCase): self.assertContains(response, '<tr class="model-actor">') self.assertContains(response, '<tr class="model-album">') + def testAppModelInFormBodyClass(self): + """ + Ensure app and model tag are correcly read by change_form template + """ + response = self.client.get('/test_admin/admin/admin_views/section/add/') + self.assertEqual(response.status_code, 200) + self.assertContains(response, + '<body class="app-admin_views model-section ') + + def testAppModelInListBodyClass(self): + """ + Ensure app and model tag are correcly read by change_list template + """ + response = self.client.get('/test_admin/admin/admin_views/section/') + self.assertEqual(response.status_code, 200) + self.assertContains(response, + '<body class="app-admin_views model-section ') + + def testAppModelInDeleteConfirmationBodyClass(self): + """ + Ensure app and model tag are correcly read by delete_confirmation + template + """ + response = self.client.get( + '/test_admin/admin/admin_views/section/1/delete/') + self.assertEqual(response.status_code, 200) + self.assertContains(response, + '<body class="app-admin_views model-section ') + + def testAppModelInAppIndexBodyClass(self): + """ + Ensure app and model tag are correcly read by app_index template + """ + response = self.client.get('/test_admin/admin/admin_views/') + self.assertEqual(response.status_code, 200) + self.assertContains(response, '<body class="app-admin_views ') + + def testAppModelInDeleteSelectedConfirmationBodyClass(self): + """ + Ensure app and model tag are correcly read by + delete_selected_confirmation template + """ + action_data = { + ACTION_CHECKBOX_NAME: [1], + 'action': 'delete_selected', + 'index': 0, + } + response = self.client.post('/test_admin/admin/admin_views/section/', + action_data) + self.assertEqual(response.status_code, 200) + self.assertContains(response, + '<body class="app-admin_views model-section ') + try: import docutils except ImportError: |
