Ticket #8005: 8005.1.diff
File 8005.1.diff, 2.9 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/options.py
324 324 def get_formsets(self, request, obj=None): 325 325 for inline in self.inline_instances: 326 326 yield inline.get_formset(request, obj) 327 327 328 def save_model_add(self, request, form, formsets): 329 new_object = form.save(commit=True) 330 331 if formsets: 332 for formset in formsets: 333 # HACK: it seems like the parent obejct should be passed into 334 # a method of something, not just set as an attribute 335 formset.instance = new_object 336 formset.save() 337 338 return new_object 339 328 340 def save_add(self, request, form, formsets, post_url_continue): 329 341 """ 330 342 Saves the object in the "add" stage and returns an HttpResponseRedirect. … … 333 345 """ 334 346 from django.contrib.admin.models import LogEntry, ADDITION 335 347 opts = self.model._meta 336 new_object = form.save(commit=True) 337 338 if formsets: 339 for formset in formsets: 340 # HACK: it seems like the parent obejct should be passed into 341 # a method of something, not just set as an attribute 342 formset.instance = new_object 343 formset.save() 344 348 349 new_object = self.save_model_add(request, form, formsets) 350 345 351 pk_value = new_object._get_pk_val() 346 352 LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, pk_value, force_unicode(new_object), ADDITION) 347 353 msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_object} … … 371 377 post_url = '../../../' 372 378 return HttpResponseRedirect(post_url) 373 379 save_add = transaction.commit_on_success(save_add) 374 380 381 def save_model_change(self, request, form, formsets): 382 new_object = form.save(commit=True) 383 384 if formsets: 385 for formset in formsets: 386 formset.save() 387 388 return new_object 389 375 390 def save_change(self, request, form, formsets=None): 376 391 """ 377 392 Saves the object in the "change" stage and returns an HttpResponseRedirect. … … 382 397 """ 383 398 from django.contrib.admin.models import LogEntry, CHANGE 384 399 opts = self.model._meta 385 new_object = form.save(commit=True) 400 401 new_object = self.save_model_change(request, form, formsets) 402 386 403 pk_value = new_object._get_pk_val() 387 388 if formsets: 389 for formset in formsets: 390 formset.save() 391 404 392 405 # Construct the change message. 393 406 change_message = [] 394 407 if form.changed_data: