Ticket #13166: modeladmin-13166-js-warnings-i18n.diff
File modeladmin-13166-js-warnings-i18n.diff, 16.2 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/media/js/actions.min.js
1 (function(a){a.fn.actions=function( g){var b=a.extend({},a.fn.actions.defaults,g),e=a(this);checker=function(c){c?showQuestion():reset();a(e).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)};updateCounter=function(){var c=a(e).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},true));a(b.allToggle).attr("checked",function(){if(c==e.length){value=true;showQuestion()}else{value=1 (function(a){a.fn.actions=function(h){var b=a.extend({},a.fn.actions.defaults,h),e=a(this),f=false;checker=function(c){c?showQuestion():reset();a(e).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)};updateCounter=function(){var c=a(e).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},true));a(b.allToggle).attr("checked",function(){if(c==e.length){value=true;showQuestion()}else{value= 2 2 false;clearAcross()}return value})};showQuestion=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()};showClear=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()};reset=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()};clearAcross=function(){reset();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)}; 3 3 a(b.counterContainer).show();a(this).filter(":checked").each(function(){a(this).parent().parent().toggleClass(b.selectedClass);updateCounter();a(b.acrossInput).val()==1&&showClear()});a(b.allToggle).show().click(function(){checker(a(this).attr("checked"));updateCounter()});a("div.actions span.question a").click(function(c){c.preventDefault();a(b.acrossInput).val(1);showClear()});a("div.actions span.clear a").click(function(c){c.preventDefault();a(b.allToggle).attr("checked",false);clearAcross();checker(0); 4 updateCounter()});lastChecked=null;a(e).click(function(c){if(!c)c=window.event;var d=c.target?c.target:c.srcElement;if(lastChecked&&a.data(lastChecked)!=a.data(d)&&c.shiftKey==true){var f=false;a(lastChecked).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(e).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))f=f?false:true;f&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass, 5 d.checked);lastChecked=d;updateCounter()})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery); 4 updateCounter()});lastChecked=null;a(e).click(function(c){if(!c)c=window.event;var d=c.target?c.target:c.srcElement;if(lastChecked&&a.data(lastChecked)!=a.data(d)&&c.shiftKey==true){var g=false;a(lastChecked).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(e).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))g=g?false:true;g&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass, 5 d.checked);lastChecked=d;updateCounter()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){f=true});a('form#changelist-form button[name="index"]').click(function(){if(f)return(answer=confirm(gettext("You have unsaved changes on individual editable fields. If you run this action, your unsaved changes will be lost.")))?true:false});a('form#changelist-form input[name="_save"]').click(function(){var c=false;a("div.actions select option:selected").each(function(){if(a(this).val()!= 6 "")c=true});if(c&&!f)return(answer=confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button.")))?true:false;if(c&&f)return(answer=confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")))?true:false})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter", 7 allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery); -
django/contrib/admin/media/js/actions.js
2 2 $.fn.actions = function(opts) { 3 3 var options = $.extend({}, $.fn.actions.defaults, opts); 4 4 var actionCheckboxes = $(this); 5 var list_editable_changed = false; 5 6 checker = function(checked) { 6 7 if (checked) { 7 8 showQuestion(); … … 100 101 lastChecked = target; 101 102 updateCounter(); 102 103 }); 104 $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() { 105 list_editable_changed = true; 106 }); 107 $('form#changelist-form button[name="index"]').click(function(event) { 108 if (list_editable_changed) { 109 answer = confirm(gettext("You have unsaved changes on individual editable fields. If you run this action, your unsaved changes will be lost.")); 110 if (answer) { return true } 111 else { return false }; 112 } 113 }); 114 $('form#changelist-form input[name="_save"]').click(function(event) { 115 var action_changed = false; 116 $('div.actions select option:selected').each(function() { 117 if ($(this).val() != "") { 118 action_changed = true; 119 } 120 }); 121 if (action_changed && !list_editable_changed) { 122 answer = confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button.")); 123 if (answer) { return true } 124 else { return false }; 125 } 126 if (action_changed && list_editable_changed) { 127 answer = confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")); 128 if (answer) { return true } 129 else { return false }; 130 } 131 }); 103 132 } 104 133 /* Setup plugin defaults */ 105 134 $.fn.actions.defaults = { -
django/contrib/admin/options.py
737 737 738 738 # Get the list of selected PKs. If nothing's selected, we can't 739 739 # perform an action on it, so bail. Except we want to perform 740 # the action explicit ely on all objects.740 # the action explicitly on all objects. 741 741 selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME) 742 742 if not selected and not select_across: 743 743 # Reminder that something needs to be selected or nothing will happen … … 761 761 else: 762 762 msg = _("No action selected.") 763 763 self.message_user(request, msg) 764 return None 764 765 765 766 @csrf_protect_m 766 767 @transaction.commit_on_success … … 979 980 return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') 980 981 981 982 # If the request was POSTed, this might be a bulk action or a bulk edit. 982 # Try to look up an action or confirmation first, but if this isn't an 983 # action the POST will fall through to the bulk edit check, below. 984 if actions and request.method == 'POST' and (helpers.ACTION_CHECKBOX_NAME in request.POST or 'index' in request.POST): 985 response = self.response_action(request, queryset=cl.get_query_set()) 986 if response: 987 return response 983 # Try to look up an action or confirmation first, but if this isn't an action the POST 984 # will fall through to the bulk edit check, below. 988 985 986 action_failed = False 987 988 # Actions with no confirmation 989 if actions and request.method == 'POST' and 'index' in request.POST and '_save' not in request.POST: 990 if len(request.POST.get(helpers.ACTION_CHECKBOX_NAME, [])): 991 response = self.response_action(request, queryset=cl.get_query_set()) 992 if response: 993 return response 994 else: 995 action_failed = True 996 else: 997 msg = _("Items must be selected in order to perform actions on them. No items have been changed.") 998 self.message_user(request, msg) 999 action_failed = True 1000 1001 # Actions with confirmation 1002 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: 1003 if len(request.POST.get(helpers.ACTION_CHECKBOX_NAME, [])): 1004 response = self.response_action(request, queryset=cl.get_query_set()) 1005 if response: 1006 return response 1007 else: 1008 action_failed = True 1009 1010 989 1011 # If we're allowing changelist editing, we need to construct a formset 990 1012 # for the changelist given all the fields to be edited. Then we'll 991 1013 # use the formset to validate/process POSTed data. 992 1014 formset = cl.formset = None 993 1015 994 1016 # Handle POSTed bulk-edit data. 995 if request.method == "POST" and self.list_editable :1017 if request.method == "POST" and self.list_editable and '_save' in request.POST and not action_failed: 996 1018 FormSet = self.get_changelist_formset(request) 997 1019 formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list) 998 1020 if formset.is_valid(): -
django/contrib/admin/templates/admin/change_list.html
85 85 {% endif %} 86 86 {% endblock %} 87 87 88 <form action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}88 <form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %} 89 89 {% if cl.formset %} 90 90 {{ cl.formset.management_form }} 91 91 {% endif %} -
django/contrib/admin/templates/admin/change_list_results.html
1 1 {% if results %} 2 <table cellspacing="0" >2 <table cellspacing="0" id="result_list"> 3 3 <thead> 4 4 <tr> 5 5 {% for header in result_headers %}<th{{ header.class_attrib }}> -
tests/regressiontests/admin_views/tests.py
1091 1091 "form-2-alive": "checked", 1092 1092 "form-2-gender": "1", 1093 1093 "form-2-id": "3", 1094 1095 "_save": "Save", 1094 1096 } 1095 1097 response = self.client.post('/test_admin/admin/admin_views/person/', 1096 1098 data, follow=True) … … 1111 1113 "form-2-alive": "checked", 1112 1114 "form-2-gender": "1", 1113 1115 "form-2-id": "3", 1116 1117 "_save": "Save", 1114 1118 } 1115 1119 self.client.post('/test_admin/admin/admin_views/person/', data) 1116 1120 … … 1130 1134 "form-1-id": "3", 1131 1135 "form-1-gender": "1", 1132 1136 "form-1-alive": "checked", 1137 1138 "_save": "Save", 1133 1139 } 1134 1140 self.client.post('/test_admin/admin/admin_views/person/?gender__exact=1', data) 1135 1141 … … 1142 1148 "form-MAX_NUM_FORMS": "0", 1143 1149 1144 1150 "form-0-id": "1", 1145 "form-0-gender": "1" 1151 "form-0-gender": "1", 1152 1153 "_save": "Save", 1146 1154 } 1147 1155 self.client.post('/test_admin/admin/admin_views/person/?q=mauchly', data) 1148 1156 … … 1158 1166 "form-0-id": "2", 1159 1167 "form-0-alive": "1", 1160 1168 "form-0-gender": "2", 1169 1170 # Ensure that the form processing understands this as a list_editable "Save" 1171 # and not an action "Go". 1172 "_save": "Save", 1161 1173 } 1162 1174 response = self.client.post('/test_admin/admin/admin_views/person/', data) 1163 1175 self.assertContains(response, "Grace is not a Zombie") … … 1172 1184 "form-0-id": "2", 1173 1185 "form-0-alive": "1", 1174 1186 "form-0-gender": "2", 1187 1188 "_save": "Save", 1175 1189 } 1176 1190 response = self.client.post('/test_admin/admin/admin_views/person/', data) 1177 1191 non_form_errors = response.context['cl'].formset.non_form_errors() … … 1207 1221 "form-3-order": "0", 1208 1222 "form-3-id": "4", 1209 1223 "form-3-collector": "1", 1224 1225 # Ensure that the form processing understands this as a list_editable "Save" 1226 # and not an action "Go". 1227 "_save": "Save", 1210 1228 } 1211 1229 response = self.client.post('/test_admin/admin/admin_views/category/', data) 1212 1230 # Successful post will redirect … … 1218 1236 self.failUnlessEqual(Category.objects.get(id=3).order, 1) 1219 1237 self.failUnlessEqual(Category.objects.get(id=4).order, 0) 1220 1238 1239 def test_list_editable_action_submit(self): 1240 # List editable changes should not be executed if the action "Go" button is 1241 # used to submit the form. 1242 data = { 1243 "form-TOTAL_FORMS": "3", 1244 "form-INITIAL_FORMS": "3", 1245 "form-MAX_NUM_FORMS": "0", 1246 1247 "form-0-gender": "1", 1248 "form-0-id": "1", 1249 1250 "form-1-gender": "2", 1251 "form-1-id": "2", 1252 1253 "form-2-alive": "checked", 1254 "form-2-gender": "1", 1255 "form-2-id": "3", 1256 1257 "index": "0", 1258 "_selected_action": [u'3'], 1259 "action": [u'', u'delete_selected'], 1260 } 1261 self.client.post('/test_admin/admin/admin_views/person/', data) 1262 1263 self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, True) 1264 self.failUnlessEqual(Person.objects.get(name="Grace Hopper").gender, 1) 1265 1266 def test_list_editable_action_choices(self): 1267 # List editable changes should be executed if the "Save" button is 1268 # used to submit the form - any action choices should be ignored. 1269 data = { 1270 "form-TOTAL_FORMS": "3", 1271 "form-INITIAL_FORMS": "3", 1272 "form-MAX_NUM_FORMS": "0", 1273 1274 "form-0-gender": "1", 1275 "form-0-id": "1", 1276 1277 "form-1-gender": "2", 1278 "form-1-id": "2", 1279 1280 "form-2-alive": "checked", 1281 "form-2-gender": "1", 1282 "form-2-id": "3", 1283 1284 "_save": "Save", 1285 "_selected_action": [u'1'], 1286 "action": [u'', u'delete_selected'], 1287 } 1288 self.client.post('/test_admin/admin/admin_views/person/', data) 1289 1290 self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, False) 1291 self.failUnlessEqual(Person.objects.get(name="Grace Hopper").gender, 2) 1292 1293 1294 1295 1221 1296 class AdminSearchTest(TestCase): 1222 1297 fixtures = ['admin-views-users','multiple-child-classes'] 1223 1298