Skip to content

Commit

Permalink
[1.1.X] Fixed #11057: having no actions in the admin (actions=None)…
Browse files Browse the repository at this point in the history
… no longer messes up the layout. Thanks, rvdrijst.

Backport of [11670] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11671 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jacobian committed Oct 27, 2009
1 parent 97ee7a3 commit 1ab0b23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/admin/media/css/changelists.css
Expand Up @@ -53,7 +53,7 @@
vertical-align: middle;
}

#changelist table thead th:first-child {
#changelist table thead th.action-checkbox-column {
width: 1.5em;
text-align: center;
}
Expand Down
5 changes: 5 additions & 0 deletions django/contrib/admin/templatetags/admin_list.py
Expand Up @@ -106,6 +106,11 @@ def result_headers(cl):
else:
header = field_name
header = header.replace('_', ' ')
# if the field is the action checkbox: no sorting and special class
if field_name == 'action_checkbox':
yield {"text": header,
"class_attrib": mark_safe(' class="action-checkbox-column"')}
continue

# It is a non-field, but perhaps one that is sortable
admin_order_field = getattr(attr, "admin_order_field", None)
Expand Down
10 changes: 10 additions & 0 deletions tests/regressiontests/admin_views/tests.py
Expand Up @@ -1140,6 +1140,16 @@ def test_model_without_action(self):
'<input type="checkbox" class="action-select"' not in response.content,
"Found an unexpected action toggle checkboxbox in response"
)
self.assert_('action-checkbox-column' not in response.content,
"Found unexpected action-checkbox-column class in response")

def test_action_column_class(self):
"Tests that the checkbox column class is present in the response"
response = self.client.get('/test_admin/admin/admin_views/subscriber/')
self.assertNotEquals(response.context["action_form"], None)
self.assert_('action-checkbox-column' in response.content,
"Expected an action-checkbox-column in response")


def test_multiple_actions_form(self):
"""
Expand Down

0 comments on commit 1ab0b23

Please sign in to comment.