Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#10505 closed (fixed)

Integrate django-batchadmin

Reported by: Jannis Leidel Owned by: Jacob
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Martin Mahner Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The integration of django-batchadmin is one of the "maby" features of 1.1 (Admin-02).

It allows the user to define lists of callables in ModelAdmin classes that are used to perform custom actions on a list of objects retrieved from checkbox inputs.

Attachments (10)

admin-actions.1.diff (15.9 KB ) - added by Jannis Leidel 15 years ago.
Initial patch, partly based on django-batchadmin
admin-actions.2.diff (23.9 KB ) - added by Jannis Leidel 15 years ago.
Refactored action loading and choices. Only the queryset of the selection is passed to actions (in model admin methods and function) now. Model methods don't get the whole queryset anymore but are called each (~obj.action()). Added tests, yay!
admin-actions.3.diff (24.4 KB ) - added by Jannis Leidel 15 years ago.
Small fix for admin_registration tests
admin-actions.4.diff (24.4 KB ) - added by Jannis Leidel 15 years ago.
Fixed redundancy in condition with callable_actions dictionary
admin-actions.5.diff (24.4 KB ) - added by Jannis Leidel 15 years ago.
Isolated the logic to look for callable actions inside the get_action method
admin-actions.6.diff (29.9 KB ) - added by Jannis Leidel 15 years ago.
Updated to work with merged list_editable code. Now only passes the queryset to response_action method and fixes some stylesheet issues.
admin-actions.7.diff (34.4 KB ) - added by Jannis Leidel 15 years ago.
Fixed problem with URLs in delete_selected action in a backwards compatible way.
admin-actions.8.diff (34.6 KB ) - added by Martin Mahner 15 years ago.
URL resolving now takes care of AdminSite's
admin-actions.9.diff (34.8 KB ) - added by Jannis Leidel 15 years ago.
Refactored get_action code. Removed support for model level actions. Added ability to add actions to all model admins of a admin site. Subclasses are now loaded from subclasses, too (get_actions). Now passes the request to get_actions and get_action_choices, e.g. for user permission dependent actions. Courtesy of Alex Gaynor
admin-actions.diff (34.7 KB ) - added by Alex Gaynor 15 years ago.

Download all attachments as: .zip

Change History (18)

by Jannis Leidel, 15 years ago

Attachment: admin-actions.1.diff added

Initial patch, partly based on django-batchadmin

comment:1 by Jannis Leidel, 15 years ago

Has patch: set
Needs documentation: set
Needs tests: set
Owner: changed from nobody to Jannis Leidel
Status: newassigned

The current code can also be found at Github, http://github.com/jezdez/django/commits/admin-actions.

The code differs from django-batchadmin in multiple ways:

  • Removed dependency on jQuery, added unobtrusive Actions code
  • Replaced select/deselect button with global checkbox (screenshot: http://www.quicksnapper.com/jezdez/image/batchadmin)
  • Added ability to directly use callables as actions, also looks in model class for action with given name (~list_display)
  • Fixes various bugs in batchadmin regarding non-ASCII data, e.g. i18n

Needs tests and docs

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Jacob, 15 years ago

milestone: 1.11.1 beta
Owner: changed from Jannis Leidel to Jacob
Status: assignednew

by Jannis Leidel, 15 years ago

Attachment: admin-actions.2.diff added

Refactored action loading and choices. Only the queryset of the selection is passed to actions (in model admin methods and function) now. Model methods don't get the whole queryset anymore but are called each (~obj.action()). Added tests, yay!

by Jannis Leidel, 15 years ago

Attachment: admin-actions.3.diff added

Small fix for admin_registration tests

by Jannis Leidel, 15 years ago

Attachment: admin-actions.4.diff added

Fixed redundancy in condition with callable_actions dictionary

by Jannis Leidel, 15 years ago

Attachment: admin-actions.5.diff added

Isolated the logic to look for callable actions inside the get_action method

by Jannis Leidel, 15 years ago

Attachment: admin-actions.6.diff added

Updated to work with merged list_editable code. Now only passes the queryset to response_action method and fixes some stylesheet issues.

comment:4 by Jannis Leidel, 15 years ago

Oh, the last patch also includes a better default delete action that will ask for confirmation before deleting, courtesy of Martin Mahner.

by Jannis Leidel, 15 years ago

Attachment: admin-actions.7.diff added

Fixed problem with URLs in delete_selected action in a backwards compatible way.

comment:5 by Jacob, 15 years ago

There's a set of usecases I shared with jezdez that I want this to solve; posting 'em here for posterity:

  1. I want to be able to add an action to a particular modeladmin and have that action available. I assume this works :)
  2. I want to be able to create an abstract ModelAdmin subclass -- think GeoAdmin -- that has actions available to any admin registered with that subclass or any of *its* subclasses.
  3. I want to be able to define some abstract function and make it available for anyone who wants to use it as an action on some modeladmin I don't know anything about (this is the reusable app usecase).
  4. I want to be able to create an action that's available on every registered model on my site that doesn't explicitly exclude that action. Think a "csv export" reusable app that provides an "Export" feature on every changelist.
  5. Finally, I want to be able to reach in and dynamically add an action to some other model admin -- think reaching in and adding a "ban this user" action to UserAdmin.

comment:6 by Martin Mahner, 15 years ago

Cc: Martin Mahner added

by Martin Mahner, 15 years ago

Attachment: admin-actions.8.diff added

URL resolving now takes care of AdminSite's

by Jannis Leidel, 15 years ago

Attachment: admin-actions.9.diff added

Refactored get_action code. Removed support for model level actions. Added ability to add actions to all model admins of a admin site. Subclasses are now loaded from subclasses, too (get_actions). Now passes the request to get_actions and get_action_choices, e.g. for user permission dependent actions. Courtesy of Alex Gaynor

by Alex Gaynor, 15 years ago

Attachment: admin-actions.diff added

comment:7 by Jacob, 15 years ago

Resolution: fixed
Status: newclosed

(In [10121]) Fixed #10505: added support for bulk admin actions, including a globally-available "delete selected" action. See the documentation for details.

This work started life as Brian Beck's "django-batchadmin." It was rewritten for inclusion in Django by Alex Gaynor, Jannis Leidel (jezdez), and Martin Mahner (bartTC). Thanks, guys!

comment:8 by Jacob, 13 years ago

milestone: 1.1 beta

Milestone 1.1 beta deleted

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