Ticket #33977: django-actions.patch

File django-actions.patch, 1.7 KB (added by Willem Van Onsem, 2 years ago)
  • django/contrib/admin/decorators.py

    diff --git a/django/contrib/admin/decorators.py b/django/contrib/admin/decorators.py
    index d3ff56a59a..ad34df2e65 100644
    a b  
    1 def action(function=None, *, permissions=None, description=None):
     1def action(function=None, *, permissions=None, description=None, group=None):
    22    """
    33    Conveniently add attributes to an action function::
    44
    def action(function=None, *, permissions=None, description=None):  
    2323            func.allowed_permissions = permissions
    2424        if description is not None:
    2525            func.short_description = description
     26        if group is not None:
     27            func.action_group = group
    2628        return func
    2729
    2830    if function is None:
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 8ccacd6213..ca61901fe7 100644
    a b  
    11import copy
     2from collections import defaultdict
    23import json
    34import re
    45from functools import partial, update_wrapper
    class ModelAdmin(BaseModelAdmin):  
    10241025        Return a list of choices for use in a form object.  Each choice is a
    10251026        tuple (name, description).
    10261027        """
     1028        choices = defaultdict(list)
     1029        choices[None].extend(default_choices)
    10271030        choices = [] + default_choices
    10281031        for func, name, description in self.get_actions(request).values():
    10291032            choice = (name, description % model_format_dict(self.opts))
    1030             choices.append(choice)
    1031         return choices
     1033            choices[getattr(func, 'action_group', None)].append(choice)
     1034        return list(choices.items())
    10321035
    10331036    def get_action(self, action):
    10341037        """
Back to Top