From dcbb060e140fd398596162fc0d141aab020401f6 Mon Sep 17 00:00:00 2001 From: Patrick Beeson Date: Mon, 10 Nov 2014 15:04:55 -0500 Subject: [PATCH 1/2] Change force_unicode to force_text for python3 compatibility. --- nested_inline/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nested_inline/admin.py b/nested_inline/admin.py index c0740ba..68bfb16 100644 --- a/nested_inline/admin.py +++ b/nested_inline/admin.py @@ -5,7 +5,7 @@ from django.forms.formsets import all_valid from django.http import Http404 from django.utils.decorators import method_decorator -from django.utils.encoding import force_unicode +from django.utils.encoding import force_text from django.views.decorators.csrf import csrf_protect from django.utils.translation import ugettext as _ from django.contrib.admin.util import unquote @@ -225,7 +225,7 @@ def add_view(self, request, form_url='', extra_context=None): media += self.wrap_nested_inline_formsets(request, inline, formset) context = { - 'title': _('Add %s') % force_unicode(opts.verbose_name), + 'title': _('Add %s') % force_text(opts.verbose_name), 'adminform': adminForm, 'is_popup': "_popup" in request.REQUEST, 'show_delete': False, @@ -250,7 +250,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): raise PermissionDenied if obj is None: - raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)}) + raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(opts.verbose_name), 'key': escape(object_id)}) if request.method == 'POST' and "_saveasnew" in request.POST: return self.add_view(request, form_url=reverse('admin:%s_%s_add' % @@ -321,7 +321,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): media += self.wrap_nested_inline_formsets(request, inline, formset) context = { - 'title': _('Change %s') % force_unicode(opts.verbose_name), + 'title': _('Change %s') % force_text(opts.verbose_name), 'adminform': adminForm, 'object_id': object_id, 'original': obj, From 79fdefd519f0dd7ef2ca0cb59fd644911efc13be Mon Sep 17 00:00:00 2001 From: Patrick Beeson Date: Mon, 10 Nov 2014 16:51:40 -0500 Subject: [PATCH 2/2] Remove commit_on_success decorator and replace with atomic per Django deprication policy. --- nested_inline/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nested_inline/admin.py b/nested_inline/admin.py index 68bfb16..f9cd506 100644 --- a/nested_inline/admin.py +++ b/nested_inline/admin.py @@ -144,7 +144,7 @@ def all_valid_with_nesting(self, formsets): return True @csrf_protect_m - @transaction.commit_on_success + @transaction.atomic def add_view(self, request, form_url='', extra_context=None): "The 'add' admin view for this model." model = self.model @@ -238,7 +238,7 @@ def add_view(self, request, form_url='', extra_context=None): return self.render_change_form(request, context, form_url=form_url, add=True) @csrf_protect_m - @transaction.commit_on_success + @transaction.atomic def change_view(self, request, object_id, form_url='', extra_context=None): "The 'change' admin view for this model." model = self.model