Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10734 closed (fixed)

Admin actions: use SortedDict instead of dict for predictable actions order

Reported by: kmike Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: kmike84@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I think the ability to define order of actions is a nice usability feature. The order of admin actions in drop-down menu now depends on internal python dict representation. If in get_actions function we use

actions = SortedDict()

instead of

actions = {}

actions wil have fixed order: the ones defined first will come on the top of the list. For example, if we define some custom actions using

actions=['action1', 'action2']

action1 will be before action2 in drop-down. For reverse order we will be able to write

actions=['action2', 'action1'].

Attachments (1)

actions-sorted.diff (974 bytes) - added by Alex 5 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by Alex

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by Alex

comment:2 Changed 5 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [10408]) Made a bunch of improvements to admin actions. Be warned: this includes one minor but BACKWARDS-INCOMPATIBLE change.

These changes are:

  • BACKWARDS-INCOMPATIBLE CHANGE: action functions and action methods now share the same signature: (modeladmin, request, queryset). Actions defined as methods stay the same, but if you've defined an action as a standalone function you'll now need to add that first modeladmin argument.
  • The delete selected action is now a standalone function registered site-wide; this makes disabling it easy.
  • Fixed #10596: there are now official, documented AdminSite APIs for dealing with actions, including a method to disable global actions. You can still re-enable globally-disabled actions on a case-by-case basis.
  • Fixed #10595: you can now disable actions for a particular ModelAdmin by setting actions to None.
  • Fixed #10734: actions are now sorted (by name).
  • Fixed #10618: the action is now taken from the form whose "submit" button you clicked, not arbitrarily the last form on the page.
  • All of the above is documented and tested.

comment:3 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.