Ticket #11057: actions_patch.diff

File actions_patch.diff, 2.3 KB (added by rvdrijst, 6 years ago)

Patch with fix and tests

  • django/contrib/admin/media/css/changelists.css

     
    5353    vertical-align: middle;
    5454}
    5555
    56 #changelist table thead th:first-child {
     56#changelist table thead th.action-checkbox-column {
    5757    width: 1.5em;
    5858    text-align: center;
    5959}
  • django/contrib/admin/templatetags/admin_list.py

     
    106106                    else:
    107107                        header = field_name
    108108                    header = header.replace('_', ' ')
     109            # if the field is the action checkbox: no sorting and special class
     110            if field_name == 'action_checkbox':
     111                yield {"text": header,
     112                       "class_attrib": mark_safe(' class="action-checkbox-column"')}
     113                continue
    109114
    110115            # It is a non-field, but perhaps one that is sortable
    111116            admin_order_field = getattr(attr, "admin_order_field", None)
  • tests/regressiontests/admin_views/tests.py

     
    10831083            '<input type="checkbox" class="action-select"' not in response.content,
    10841084            "Found an unexpected action toggle checkboxbox in response"
    10851085        )
     1086        self.assert_('action-checkbox-column' not in response.content,
     1087            "Found unexpected action-checkbox-column class in response")
     1088
     1089    def test_action_column_class(self):
     1090        "Tests that the checkbox column class is present in the response"
     1091        response = self.client.get('/test_admin/admin/admin_views/subscriber/')
     1092        self.assertNotEquals(response.context["action_form"], None)
     1093        self.assert_('action-checkbox-column' in response.content,
     1094            "Expected an action-checkbox-column in response")
     1095
    10861096
    10871097    def test_multiple_actions_form(self):
    10881098        """
Back to Top