Commit 44f30802 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

Fixed #10505: added support for bulk admin actions, including a...

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!

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10121 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 4e253343
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ answer newbie questions, and generally made Django that much better:
    Ned Batchelder <http://www.nedbatchelder.com/>
    batiste@dosimple.ch
    Batman
    Brian Beck <http://blog.brianbeck.com/>
    Shannon -jj Behrens <http://jjinux.blogspot.com/>
    Esdras Beleza <linux@esdrasbeleza.com>
    Chris Bennett <chrisrbennett@yahoo.com>
@@ -268,6 +269,7 @@ answer newbie questions, and generally made Django that much better:
    Daniel Lindsley <polarcowz@gmail.com>
    Trey Long <trey@ktrl.com>
    msaelices <msaelices@gmail.com>
    Martin Mahner <http://www.mahner.org/>
    Matt McClanahan <http://mmcc.cx/>
    Frantisek Malina <vizualbod@vizualbod.com>
    Martin Maney <http://www.chipy.org/Martin_Maney>
+1 −0
Original line number Diff line number Diff line
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
from django.contrib.admin.options import StackedInline, TabularInline
from django.contrib.admin.sites import AdminSite, site
+13 −5
Original line number Diff line number Diff line
@@ -6,6 +6,14 @@ from django.utils.safestring import mark_safe
from django.utils.encoding import force_unicode
from django.contrib.admin.util import flatten_fieldsets
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _

ACTION_CHECKBOX_NAME = '_selected_action'

class ActionForm(forms.Form):
    action = forms.ChoiceField(label=_('Action:'))

checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)

class AdminForm(object):
    def __init__(self, form, fieldsets, prepopulated_fields):
+44 −0
Original line number Diff line number Diff line
@@ -50,12 +50,24 @@

#changelist table thead th {
    white-space: nowrap;
    vertical-align: middle;
}

#changelist table thead th:first-child {
    width: 1.5em;
    text-align: center;
}

#changelist table tbody td {
    border-left: 1px solid #ddd;
}

#changelist table tbody td:first-child {
    border-left: 0;
    border-right: 1px solid #ddd;
    text-align: center;
}

#changelist table tfoot {
    color: #666;
}
@@ -209,3 +221,35 @@
    border-color: #036;
}

/* ACTIONS */

.filtered .actions {
    margin-right: 160px !important;
    border-right: 1px solid #ddd;
}

#changelist .actions {
    color: #666;
    padding: 3px;
    border-bottom: 1px solid #ddd;
    background: #e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x;
}

#changelist .actions:last-child {
    border-bottom: none;
}

#changelist .actions select {
    border: 1px solid #aaa;
    margin: 0 0.5em;
    padding: 1px 2px;
}

#changelist .actions label {
    font-size: 11px;
    margin: 0 0.5em;
}

#changelist #action-toggle {
    display: none;
}
+19 −0
Original line number Diff line number Diff line
var Actions = {
    init: function() {
        selectAll = document.getElementById('action-toggle');
        if (selectAll) {
            selectAll.style.display = 'inline';
            addEvent(selectAll, 'change', function() {
                Actions.checker(this.checked);
            });
        }
    },
    checker: function(checked) {
        actionCheckboxes = document.getElementsBySelector('tr input.action-select');
        for(var i = 0; i < actionCheckboxes.length; i++) {
            actionCheckboxes[i].checked = checked;
        }
    }
}

addEvent(window, 'load', Actions.init);
Loading