Ticket #16371: 16371.admin-field-css-classes.diff

File 16371.admin-field-css-classes.diff, 4.4 KB (added by Julien Phalip, 13 years ago)
  • django/contrib/admin/templates/admin/edit_inline/tabular.html

    diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html
    index 71b097e..b891a76 100644
    a b  
    4444        {% for fieldset in inline_admin_form %}
    4545          {% for line in fieldset %}
    4646            {% for field in line %}
    47               <td class="{{ field.field.name }}">
     47              <td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}>
    4848              {% if field.is_readonly %}
    4949                  <p>{{ field.contents }}</p>
    5050              {% else %}
  • django/contrib/admin/templates/admin/includes/fieldset.html

    diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html
    index 6363aee..0b71d50 100644
    a b  
    44        <div class="description">{{ fieldset.description|safe }}</div>
    55    {% endif %}
    66    {% for line in fieldset %}
    7         <div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% for field in line %} {{ field.field.name }}{% endfor %}">
     7        <div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
    88            {% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %}
    99            {% for field in line %}
    1010                <div{% if not line.fields|length_is:'1' %} class="field-box{% if not field.is_readonly and field.errors %} errors{% endif %}"{% endif %}>
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index b6e7b9e..b15e97a 100644
    a b class ReadonlyTest(TestCase):  
    27862786            formats.localize(datetime.date.today() - datetime.timedelta(days=7))
    27872787        )
    27882788
    2789         self.assertContains(response, '<div class="form-row coolness">')
    2790         self.assertContains(response, '<div class="form-row awesomeness_level">')
    2791         self.assertContains(response, '<div class="form-row posted">')
    2792         self.assertContains(response, '<div class="form-row value">')
    2793         self.assertContains(response, '<div class="form-row ">')
     2789        self.assertContains(response, '<div class="form-row field-coolness">')
     2790        self.assertContains(response, '<div class="form-row field-awesomeness_level">')
     2791        self.assertContains(response, '<div class="form-row field-posted">')
     2792        self.assertContains(response, '<div class="form-row field-value">')
     2793        self.assertContains(response, '<div class="form-row">')
    27942794        self.assertContains(response, '<p class="help">', 3)
    27952795        self.assertContains(response, '<p class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</p>')
    27962796        self.assertContains(response, '<p class="help">Some help text for the content (with unicode ŠĐĆŽćžšđ)</p>')
    class GroupAdminTest(TestCase):  
    29832983            self.assertEqual(response.status_code, 200)
    29842984
    29852985
     2986class CSSTest(TestCase):
     2987    urls = "regressiontests.admin_views.urls"
     2988    fixtures = ['admin-views-users.xml']
     2989
     2990    def setUp(self):
     2991        self.client.login(username='super', password='secret')
     2992
     2993    def tearDown(self):
     2994        self.client.logout()
     2995
     2996    def test_css_classes(self):
     2997        response = self.client.get('/test_admin/admin/admin_views/post/add/')
     2998
     2999        # The main form
     3000        self.assertContains(response, 'class="form-row field-title"')
     3001        self.assertContains(response, 'class="form-row field-content"')
     3002        self.assertContains(response, 'class="form-row field-public"')
     3003        self.assertContains(response, 'class="form-row field-awesomeness_level"')
     3004        self.assertContains(response, 'class="form-row field-coolness"')
     3005        self.assertContains(response, 'class="form-row field-value"')
     3006        self.assertContains(response, 'class="form-row"') # The lambda function
     3007
     3008        # The tabular inline
     3009        self.assertContains(response, '<td class="field-url">')
     3010        self.assertContains(response, '<td class="field-posted">')
     3011
     3012
    29863013try:
    29873014    import docutils
    29883015except ImportError:
Back to Top