Ticket #5735: 5735against6470.patch

File 5735against6470.patch, 1.5 KB (added by Honza Král, 17 years ago)
  • django/contrib/admin/options.py

    commit c81db5885f0a22140fefa34442bd0a3d648f3a58
    Author: Honza Král <Honza.Kral@gmail.com>
    Date:   Thu Oct 11 13:04:28 2007 +0200
    
        Wrapped admin.save_add and admin.save_change into a transaction
    
    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 76c6bf1..0365228 100644
    a b from django.contrib.contenttypes.models import ContentType  
    55from django.contrib.admin import widgets
    66from django.contrib.admin.util import get_deleted_objects
    77from django.core.exceptions import ImproperlyConfigured, PermissionDenied
    8 from django.db import models
     8from django.db import models, transaction
    99from django.http import Http404, HttpResponse, HttpResponseRedirect
    1010from django.shortcuts import get_object_or_404, render_to_response
    1111from django.utils.html import escape
    class ModelAdmin(BaseModelAdmin):  
    399399            else:
    400400                post_url = '../../../'
    401401            return HttpResponseRedirect(post_url)
     402    save_add = transaction.commit_on_success( save_add )
    402403
    403404    def save_change(self, request, model, form, formsets=None):
    404405        """
    class ModelAdmin(BaseModelAdmin):  
    449450        else:
    450451            request.user.message_set.create(message=msg)
    451452            return HttpResponseRedirect("../")
     453    save_change = transaction.commit_on_success( save_change )
    452454
    453455    def render_change_form(self, model, context, add=False, change=False, form_url=''):
    454456        opts = model._meta
Back to Top