Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

newforms-admin: Removed some places where model was being passed arou…

…nd for no reason.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7923 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 641711dd9d55dc3972d60f9a3dfbb39ba8902b73 1 parent 2624f4e
Joseph Kocherhans authored July 15, 2008

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

  1. 28  django/contrib/admin/options.py
28  django/contrib/admin/options.py
@@ -352,14 +352,14 @@ def get_formsets(self, request, obj=None):
352 352
         for inline in self.inline_instances:
353 353
             yield inline.get_formset(request, obj)
354 354
 
355  
-    def save_add(self, request, model, form, formsets, post_url_continue):
  355
+    def save_add(self, request, form, formsets, post_url_continue):
356 356
         """
357 357
         Saves the object in the "add" stage and returns an HttpResponseRedirect.
358 358
 
359 359
         `form` is a bound Form instance that's verified to be valid.
360 360
         """
361 361
         from django.contrib.admin.models import LogEntry, ADDITION
362  
-        opts = model._meta
  362
+        opts = self.model._meta
363 363
         new_object = form.save(commit=True)
364 364
 
365 365
         if formsets:
@@ -370,7 +370,7 @@ def save_add(self, request, model, form, formsets, post_url_continue):
370 370
                 formset.save()
371 371
 
372 372
         pk_value = new_object._get_pk_val()
373  
-        LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), ADDITION)
  373
+        LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, pk_value, force_unicode(new_object), ADDITION)
374 374
         msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_object}
375 375
         # Here, we distinguish between different save types by checking for
376 376
         # the presence of keys in request.POST.
@@ -399,7 +399,7 @@ def save_add(self, request, model, form, formsets, post_url_continue):
399 399
             return HttpResponseRedirect(post_url)
400 400
     save_add = transaction.commit_on_success(save_add)
401 401
 
402  
-    def save_change(self, request, model, form, formsets=None):
  402
+    def save_change(self, request, form, formsets=None):
403 403
         """
404 404
         Saves the object in the "change" stage and returns an HttpResponseRedirect.
405 405
 
@@ -408,7 +408,7 @@ def save_change(self, request, model, form, formsets=None):
408 408
         `formsets` is a sequence of InlineFormSet instances that are verified to be valid.
409 409
         """
410 410
         from django.contrib.admin.models import LogEntry, CHANGE
411  
-        opts = model._meta
  411
+        opts = self.model._meta
412 412
         new_object = form.save(commit=True)
413 413
         pk_value = new_object._get_pk_val()
414 414
 
@@ -439,7 +439,7 @@ def save_change(self, request, model, form, formsets=None):
439 439
         change_message = ' '.join(change_message)
440 440
         if not change_message:
441 441
             change_message = _('No fields changed.')
442  
-        LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), CHANGE, change_message)
  442
+        LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, pk_value, force_unicode(new_object), CHANGE, change_message)
443 443
 
444 444
         msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
445 445
         if request.POST.has_key("_continue"):
@@ -459,8 +459,8 @@ def save_change(self, request, model, form, formsets=None):
459 459
             return HttpResponseRedirect("../")
460 460
     save_change = transaction.commit_on_success(save_change)
461 461
 
462  
-    def render_change_form(self, request, model, context, add=False, change=False, form_url='', obj=None):
463  
-        opts = model._meta
  462
+    def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
  463
+        opts = self.model._meta
464 464
         app_label = opts.app_label
465 465
         ordered_objects = opts.get_ordered_objects()
466 466
         context.update({
@@ -470,11 +470,11 @@ def render_change_form(self, request, model, context, add=False, change=False, f
470 470
             'has_change_permission': self.has_change_permission(request, obj),
471 471
             'has_delete_permission': self.has_delete_permission(request, obj),
472 472
             'has_file_field': True, # FIXME - this should check if form or formsets have a FileField,
473  
-            'has_absolute_url': hasattr(model, 'get_absolute_url'),
  473
+            'has_absolute_url': hasattr(self.model, 'get_absolute_url'),
474 474
             'ordered_objects': ordered_objects,
475 475
             'form_url': mark_safe(form_url),
476 476
             'opts': opts,
477  
-            'content_type_id': ContentType.objects.get_for_model(model).id,
  477
+            'content_type_id': ContentType.objects.get_for_model(self.model).id,
478 478
             'save_as': self.save_as,
479 479
             'save_on_top': self.save_on_top,
480 480
             'root_path': self.admin_site.root_path,
@@ -511,7 +511,7 @@ def add_view(self, request, form_url='', extra_context=None):
511 511
                     instance=obj, save_as_new=request.POST.has_key("_saveasnew"))
512 512
                 inline_formsets.append(inline_formset)
513 513
             if all_valid(inline_formsets) and form.is_valid():
514  
-                return self.save_add(request, model, form, inline_formsets, '../%s/')
  514
+                return self.save_add(request, form, inline_formsets, '../%s/')
515 515
         else:
516 516
             form = ModelForm(initial=dict(request.GET.items()))
517 517
             for FormSet in self.get_formsets(request):
@@ -540,7 +540,7 @@ def add_view(self, request, form_url='', extra_context=None):
540 540
             'root_path': self.admin_site.root_path,
541 541
         }
542 542
         context.update(extra_context or {})
543  
-        return self.render_change_form(request, model, context, add=True)
  543
+        return self.render_change_form(request, context, add=True)
544 544
 
545 545
     def change_view(self, request, object_id, extra_context=None):
546 546
         "The 'change' admin view for this model."
@@ -574,7 +574,7 @@ def change_view(self, request, object_id, extra_context=None):
574 574
                 inline_formsets.append(inline_formset)
575 575
 
576 576
             if all_valid(inline_formsets) and form.is_valid():
577  
-                return self.save_change(request, model, form, inline_formsets)
  577
+                return self.save_change(request, form, inline_formsets)
578 578
         else:
579 579
             form = ModelForm(instance=obj)
580 580
             for FormSet in self.get_formsets(request, obj):
@@ -618,7 +618,7 @@ def change_view(self, request, object_id, extra_context=None):
618 618
             'root_path': self.admin_site.root_path,
619 619
         }
620 620
         context.update(extra_context or {})
621  
-        return self.render_change_form(request, model, context, change=True, obj=obj)
  621
+        return self.render_change_form(request, context, change=True, obj=obj)
622 622
 
623 623
     def changelist_view(self, request, extra_context=None):
624 624
         "The 'change list' admin view for this model."

0 notes on commit 641711d

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