Ticket #13166: modeladmin-12962.diff
File modeladmin-12962.diff, 3.5 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
732 732 733 733 # Get the list of selected PKs. If nothing's selected, we can't 734 734 # perform an action on it, so bail. Except we want to perform 735 # the action explicit ely on all objects.735 # the action explicitly on all objects. 736 736 selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME) 737 737 if not selected and not select_across: 738 738 # Reminder that something needs to be selected or nothing will happen … … 756 756 else: 757 757 msg = _("No action selected.") 758 758 self.message_user(request, msg) 759 return None 759 760 760 761 @csrf_protect_m 761 762 @transaction.commit_on_success … … 974 975 return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') 975 976 976 977 # If the request was POSTed, this might be a bulk action or a bulk edit. 977 # Try to look up an action or confirmation first, but if this isn't an 978 # action the POST will fall through to the bulk edit check, below. 979 if actions and request.method == 'POST' and (helpers.ACTION_CHECKBOX_NAME in request.POST or 'index' in request.POST): 980 response = self.response_action(request, queryset=cl.get_query_set()) 981 if response: 982 return response 978 # Try to look up an action or confirmation first, but if this isn't an action the POST 979 # will fall through to the bulk edit check, below. 983 980 981 action_failed = False 982 983 # Actions with no confirmation 984 if actions and request.method == 'POST' and 'index' in request.POST and '_save' not in request.POST: 985 if len(request.POST.get(helpers.ACTION_CHECKBOX_NAME, [])): 986 response = self.response_action(request, queryset=cl.get_query_set()) 987 if response: 988 return response 989 else: 990 action_failed = True 991 else: 992 msg = _("Items must be selected in order to perform actions on them. No items have been changed.") 993 self.message_user(request, msg) 994 action_failed = True 995 996 # Actions with confirmation 997 if actions and request.method == 'POST' and helpers.ACTION_CHECKBOX_NAME in request.POST and 'index' not in request.POST and '_save' not in request.POST: 998 if len(request.POST.get(helpers.ACTION_CHECKBOX_NAME, [])): 999 response = self.response_action(request, queryset=cl.get_query_set()) 1000 if response: 1001 return response 1002 else: 1003 action_failed = True 1004 1005 984 1006 # If we're allowing changelist editing, we need to construct a formset 985 1007 # for the changelist given all the fields to be edited. Then we'll 986 1008 # use the formset to validate/process POSTed data. 987 1009 formset = cl.formset = None 988 1010 989 1011 # Handle POSTed bulk-edit data. 990 if request.method == "POST" and self.list_editable :1012 if request.method == "POST" and self.list_editable and '_save' in request.POST and not action_failed: 991 1013 FormSet = self.get_changelist_formset(request) 992 1014 formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list) 993 1015 if formset.is_valid():