Re: [Django] #33977: Grouping action in the ModelAdmin

2022-09-02 Thread Django
#33977: Grouping action in the ModelAdmin
--+--
 Reporter:  Willem Van Onsem  |Owner:  nobody
 Type:  New feature   |   Status:  closed
Component:  contrib.admin |  Version:  dev
 Severity:  Normal|   Resolution:  duplicate
 Keywords:| Triage Stage:  Unreviewed
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+--
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Duplicate of #33807.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182fdc71326-d517156f-c75c-4f42-9d11-bf49c9f4eaa6-00%40eu-central-1.amazonses.com.


Re: [Django] #33977: Grouping action in the ModelAdmin

2022-09-02 Thread Django
#33977: Grouping action in the ModelAdmin
--+--
 Reporter:  Willem Van Onsem  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  contrib.admin |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+--
Changes (by Willem Van Onsem):

 * Attachment "django-actions.patch" added.


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182fdbfad74-ce2b0eb3-376e-42e3-ab2d-c9d754ab85bf-00%40eu-central-1.amazonses.com.


[Django] #33977: Grouping action in the ModelAdmin

2022-09-02 Thread Django
#33977: Grouping action in the ModelAdmin
+
   Reporter:  Willem Van Onsem  |  Owner:  nobody
   Type:  New feature   | Status:  new
  Component:  contrib.admin |Version:  dev
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  1
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  1
  UI/UX:  0 |
+
 One can make the action dropdown visually more pleasant by introducing
 groups. This does not require a lot of logic: we can easily update the
 `@action` decorator to allow specifying an `action_group`, and by slightly
 modifying the `get_action_choices` method, we can generate a list of
 groups that contain the actions:

 {{{
 diff --git a/django/contrib/admin/decorators.py
 b/django/contrib/admin/decorators.py
 index d3ff56a59a..ad34df2e65 100644
 --- a/django/contrib/admin/decorators.py
 +++ b/django/contrib/admin/decorators.py
 @@ -1,4 +1,4 @@
 -def action(function=None, *, permissions=None, description=None):
 +def action(function=None, *, permissions=None, description=None,
 group=None):
  """
  Conveniently add attributes to an action function::

 @@ -23,6 +23,8 @@ def action(function=None, *, permissions=None,
 description=None):
  func.allowed_permissions = permissions
  if description is not None:
  func.short_description = description
 +if group is not None:
 +func.action_group = group
  return func

  if function is None:
 diff --git a/django/contrib/admin/options.py
 b/django/contrib/admin/options.py
 index 8ccacd6213..ca61901fe7 100644
 --- a/django/contrib/admin/options.py
 +++ b/django/contrib/admin/options.py
 @@ -1,4 +1,5 @@
  import copy
 +from collections import defaultdict
  import json
  import re
  from functools import partial, update_wrapper
 @@ -1024,11 +1025,13 @@ class ModelAdmin(BaseModelAdmin):
  Return a list of choices for use in a form object.  Each choice
 is a
  tuple (name, description).
  """
 +choices = defaultdict(list)
 +choices[None].extend(default_choices)
  choices = [] + default_choices
  for func, name, description in
 self.get_actions(request).values():
  choice = (name, description % model_format_dict(self.opts))
 -choices.append(choice)
 -return choices
 +choices[getattr(func, 'action_group', None)].append(choice)
 +return list(choices.items())

  def get_action(self, action):
  """
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182fdbf0bd6-3fb74845-8174-46bc-bf48-88ca35fd50c1-00%40eu-central-1.amazonses.com.