Opened 13 years ago

Closed 13 years ago

#15964 closed Bug (fixed)

Do not order admin actions by description

Reported by: Julien Phalip Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm currently dealing with a site where the admin user needs to follow a step-by-step process:

  1. Mark selected translations' status as "New"
  2. Mark selected translations' status as "Needs translation"
  3. Mark selected translations' status as "No translation needed"
  4. Mark selected translations' status as "In progress"
  5. Mark selected translations' status as "Ready for review"
  6. Mark selected translations' status as "Approved"

Therefore I've logically done the following:

class MyModelAdmin(ModelAdmin):
    actions = [mark_new, mark_needs_translation, mark_no_translation_needed, mark_in_progress, mark_ready_for_review, mark_approved]
    ...

But unfortunately the actions are automatically alphabetically ordered by description in the admin interface, i.e.:

  1. Mark selected translations' status as "Approved"
  2. Mark selected translations' status as "In progress"
  3. Mark selected translations' status as "Needs translation"
  4. Mark selected translations' status as "New"
  5. Mark selected translations' status as "No translation needed"
  6. Mark selected translations' status as "Ready for review"

This is not only confusing but also quite inflexible. I think the developers should be responsible for controlling the ordering of actions, similarly as they can control the ordering of list_display or list_filter fields.

This current behaviour doesn't seem to even be tested. Apparently the action's short_description behaviour isn't tested either. The attached patch rectifies this behaviour and adds tests to cover all this.

Attachments (2)

15964.admin-actions-ordering.diff (2.7 KB ) - added by Julien Phalip 13 years ago.
15964.admin-actions-ordering.2.diff (2.7 KB ) - added by Julien Phalip 13 years ago.
Added reference to ticket number in the tests

Download all attachments as: .zip

Change History (5)

by Julien Phalip, 13 years ago

by Julien Phalip, 13 years ago

Added reference to ticket number in the tests

comment:1 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Jannis Leidel, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Luke Plant, 13 years ago

Resolution: fixed
Status: newclosed

In [16162]:

Fixed #15964 - Do not order admin actions by description

Thanks to julien for the report and patch.

Note: See TracTickets for help on using tickets.
Back to Top