Opened 4 years ago

Closed 4 years ago

#15964 closed Bug (fixed)

Do not order admin actions by description

Reported by: julien 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:

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 4 years ago.
15964.admin-actions-ordering.2.diff (2.7 KB) - added by julien 4 years ago.
Added reference to ticket number in the tests

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by julien

Changed 4 years ago by julien

Added reference to ticket number in the tests

comment:1 Changed 4 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 4 years ago by lukeplant

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

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