Skip to content

Commit

Permalink
Restored the admin views' decorators exactly to what they were before…
Browse files Browse the repository at this point in the history
… the CBV conversion.
  • Loading branch information
jphalip committed May 27, 2012
1 parent 519c630 commit 808e9ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 4 additions & 1 deletion django/contrib/admin/options.py
Expand Up @@ -928,7 +928,8 @@ def add_view(self, request, form_url='', extra_context=None):
admin_opts=self, form_url=form_url,
extra_context=extra_context).dispatch(request)


@csrf_protect_m
@transaction.commit_on_success
def change_view(self, request, object_id, form_url='', extra_context=None):
"""
The 'change' admin view for this model.
Expand All @@ -945,6 +946,8 @@ def changelist_view(self, request, extra_context=None):
return ChangeListView(
admin_opts=self, extra_context=extra_context).dispatch(request)

@csrf_protect_m
@transaction.commit_on_success
def delete_view(self, request, object_id, extra_context=None):
"""The 'delete' admin view for this model."""
return AdminDeleteView(
Expand Down
8 changes: 0 additions & 8 deletions django/contrib/admin/views/cbv.py
Expand Up @@ -73,8 +73,6 @@ def get_template_names(self):

class ChangeListView(AdminViewMixin, TemplateView):

@csrf_protect_m
@transaction.commit_on_success
def dispatch(self, request, *args, **kwargs):
from django.contrib.admin.options import IncorrectLookupParameters

Expand Down Expand Up @@ -244,8 +242,6 @@ def get_context_data(self, **kwargs):

class AdminDeleteView(AdminViewMixin, DeleteView):

@csrf_protect_m
@transaction.commit_on_success
def dispatch(self, request, *args, **kwargs):
return super(AdminDeleteView, self).dispatch(request, *args, **kwargs)

Expand Down Expand Up @@ -326,8 +322,6 @@ def get_template_names(self):

class AdminAddView(AdminViewMixin, CreateView):

@csrf_protect_m
@transaction.commit_on_success
def dispatch(self, request, *args, **kwargs):
if not self.admin_opts.has_add_permission(request):
raise PermissionDenied
Expand Down Expand Up @@ -448,8 +442,6 @@ def get_context_data(self, **kwargs):

class AdminChangeView(AdminViewMixin, UpdateView):

@csrf_protect_m
@transaction.commit_on_success
def dispatch(self, request, *args, **kwargs):
if request.method == 'POST' and "_saveasnew" in request.POST:
return self.admin_opts.add_view(
Expand Down

0 comments on commit 808e9ad

Please sign in to comment.