Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

magic-removal: Fixed #1416 -- Fixed admin to use .create() rather tha…

…n .add() for related objects. Thanks, nesh

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 10d7f00b38b3a2315a886e7eec91edb896690659 1 parent d26558e
Adrian Holovaty authored February 28, 2006

Showing 1 changed file with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. 22  django/contrib/admin/views/main.py
22  django/contrib/admin/views/main.py
@@ -249,7 +249,7 @@ def add_stage(request, app_label, model_name, show_delete=False, form_url='', po
249 249
             # Here, we distinguish between different save types by checking for
250 250
             # the presence of keys in request.POST.
251 251
             if request.POST.has_key("_continue"):
252  
-                request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
  252
+                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
253 253
                 if request.POST.has_key("_popup"):
254 254
                     post_url_continue += "?_popup=1"
255 255
                 return HttpResponseRedirect(post_url_continue % pk_value)
@@ -257,10 +257,10 @@ def add_stage(request, app_label, model_name, show_delete=False, form_url='', po
257 257
                 return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
258 258
                     (pk_value, str(new_object).replace('"', '\\"')))
259 259
             elif request.POST.has_key("_addanother"):
260  
-                request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
  260
+                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
261 261
                 return HttpResponseRedirect(request.path)
262 262
             else:
263  
-                request.user.message_set.add(message=msg)
  263
+                request.user.message_set.create(message=msg)
264 264
                 return HttpResponseRedirect(post_url)
265 265
     else:
266 266
         # Add default data.
@@ -333,19 +333,19 @@ def change_stage(request, app_label, model_name, object_id):
333 333
 
334 334
             msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
335 335
             if request.POST.has_key("_continue"):
336  
-                request.user.message_set.add(message=msg + ' ' + _("You may edit it again below."))
  336
+                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
337 337
                 if request.REQUEST.has_key('_popup'):
338 338
                     return HttpResponseRedirect(request.path + "?_popup=1")
339 339
                 else:
340 340
                     return HttpResponseRedirect(request.path)
341 341
             elif request.POST.has_key("_saveasnew"):
342  
-                request.user.message_set.add(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
  342
+                request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
343 343
                 return HttpResponseRedirect("../%s/" % pk_value)
344 344
             elif request.POST.has_key("_addanother"):
345  
-                request.user.message_set.add(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
  345
+                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
346 346
                 return HttpResponseRedirect("../add/")
347 347
             else:
348  
-                request.user.message_set.add(message=msg)
  348
+                request.user.message_set.create(message=msg)
349 349
                 return HttpResponseRedirect("../")
350 350
     else:
351 351
         # Populate new_data with a "flattened" version of the current data.
@@ -493,7 +493,7 @@ def delete_stage(request, app_label, model_name, object_id):
493 493
         obj_display = str(obj)
494 494
         obj.delete()
495 495
         LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, object_id, obj_display, DELETION)
496  
-        request.user.message_set.add(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': opts.verbose_name, 'obj': obj_display})
  496
+        request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': opts.verbose_name, 'obj': obj_display})
497 497
         return HttpResponseRedirect("../../")
498 498
     extra_context = {
499 499
         "title": _("Are you sure?"),
@@ -504,7 +504,7 @@ def delete_stage(request, app_label, model_name, object_id):
504 504
     }
505 505
     return render_to_response(["admin/%s/%s/delete_confirmation" % (app_label, opts.object_name.lower() ),
506 506
                                "admin/%s/delete_confirmation" % app_label ,
507  
-                               "admin/delete_confirmation"], extra_context, context_instance=Context(request)) 
  507
+                               "admin/delete_confirmation"], extra_context, context_instance=template.RequestContext(request))
508 508
 delete_stage = staff_member_required(delete_stage)
509 509
 
510 510
 def history(request, app_label, model_name, object_id):
@@ -522,9 +522,9 @@ def history(request, app_label, model_name, object_id):
522 522
         'module_name': capfirst(model._meta.verbose_name_plural),
523 523
         'object': obj,
524 524
     }
525  
-    return render_to_response(["admin/%s/%s/object_history" % (app_label, opts.object_name.lower() ),
  525
+    return render_to_response(["admin/%s/%s/object_history" % (app_label, model._meta.object_name.lower()),
526 526
                                "admin/%s/object_history" % app_label ,
527  
-                               "admin/object_history"], extra_context, context_instance=Context(request)) 
  527
+                               "admin/object_history"], extra_context, context_instance=template.RequestContext(request))
528 528
 history = staff_member_required(history)
529 529
 
530 530
 class ChangeList(object):

0 notes on commit 10d7f00

Please sign in to comment.
Something went wrong with that request. Please try again.