Ticket #10595: patch_django_10595.20090324.diff

File patch_django_10595.20090324.diff, 3.0 KB (added by David Larlet, 16 years ago)

First try

  • django/contrib/admin/options.py

     
    207207        for inline_class in self.inlines:
    208208            inline_instance = inline_class(self.model, self.admin_site)
    209209            self.inline_instances.append(inline_instance)
    210         if 'action_checkbox' not in self.list_display:
     210        if 'action_checkbox' not in self.list_display and self.actions is not None:
    211211            self.list_display = ['action_checkbox'] +  list(self.list_display)
    212212        if not self.list_display_links:
    213213            for name in self.list_display:
     
    421421        """
    422422        actions = {}
    423423        for klass in [self.admin_site] + self.__class__.mro()[::-1]:
    424             for action in getattr(klass, 'actions', []):
     424            class_actions = getattr(klass, 'actions', [])
     425            if not class_actions:
     426                continue # avoid iteration over None value
     427            for action in class_actions:
    425428                func, name, description = self.get_action(action)
    426429                actions[name] = (func, name, description)
    427430        return actions
     
    948951            media = self.media
    949952           
    950953        # Build the action form and populate it with available actions.
    951         action_form = self.action_form(auto_id=None)
    952         action_form.fields['action'].choices = self.get_action_choices(request)       
     954        if self.actions is None:
     955            action_form = False
     956            actions_on_top = False
     957            actions_on_bottom = False
     958        else:
     959            action_form = self.action_form(auto_id=None)
     960            action_form.fields['action'].choices = self.get_action_choices(request)
     961            actions_on_top = self.actions_on_top
     962            actions_on_bottom = self.actions_on_bottom
    953963
    954964        context = {
    955965            'title': cl.title,
     
    960970            'root_path': self.admin_site.root_path,
    961971            'app_label': app_label,
    962972            'action_form': action_form,
    963             'actions_on_top': self.actions_on_top,
    964             'actions_on_bottom': self.actions_on_bottom,
     973            'actions_on_top': actions_on_top,
     974            'actions_on_bottom': actions_on_bottom,
    965975        }
    966976        context.update(extra_context or {})
    967977        return render_to_response(self.change_list_template or [
  • django/contrib/admin/templates/admin/change_list.html

     
    99    <script type="text/javascript" src="../../jsi18n/"></script>
    1010  {% endif %}
    1111  {{ media }}
     12  {% if not actions_on_top and not actions_on_bottom %}
     13    <style>
     14      #changelist table thead th:first-child {width: inherit}
     15    </style>
     16  {% endif %}
    1217{% endblock %}
    1318
    1419{% block bodyclass %}change-list{% endblock %}
Back to Top