From d8af54bbed256db09bf22cd27c56950a9edfaabc Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 17 Aug 2017 15:09:17 +0100 Subject: [PATCH] Remove deprecated methods from wagtailadmin.views.generic --- wagtail/wagtailadmin/views/collections.py | 12 ++--- wagtail/wagtailadmin/views/generic.py | 59 ++--------------------- 2 files changed, 11 insertions(+), 60 deletions(-) diff --git a/wagtail/wagtailadmin/views/collections.py b/wagtail/wagtailadmin/views/collections.py index 6c8aa6b697..60ae983303 100644 --- a/wagtail/wagtailadmin/views/collections.py +++ b/wagtail/wagtailadmin/views/collections.py @@ -80,7 +80,7 @@ class Delete(DeleteView): def get_collection_contents(self): collection_contents = [ - hook(self.instance) + hook(self.object) for hook in hooks.get_hooks('describe_collection_contents') ] @@ -91,8 +91,8 @@ class Delete(DeleteView): return list(filter(is_nonempty, collection_contents)) - def get_context(self): - context = super(Delete, self).get_context() + def get_context_data(self, **kwargs): + context = super(Delete, self).get_context_data(**kwargs) collection_contents = self.get_collection_contents() if collection_contents: @@ -103,13 +103,13 @@ class Delete(DeleteView): return context def post(self, request, instance_id): - self.instance = get_object_or_404(self.get_queryset(), id=instance_id) + self.object = get_object_or_404(self.get_queryset(), id=instance_id) collection_contents = self.get_collection_contents() if collection_contents: # collection is non-empty; refuse to delete it return HttpResponseForbidden() - self.instance.delete() - messages.success(request, self.success_message.format(self.instance)) + self.object.delete() + messages.success(request, self.success_message.format(self.object)) return redirect(self.index_url_name) diff --git a/wagtail/wagtailadmin/views/generic.py b/wagtail/wagtailadmin/views/generic.py index 5458c3e1f2..227251980b 100644 --- a/wagtail/wagtailadmin/views/generic.py +++ b/wagtail/wagtailadmin/views/generic.py @@ -1,7 +1,5 @@ from __future__ import absolute_import, unicode_literals -import warnings - from django.core.urlresolvers import reverse from django.shortcuts import redirect from django.utils.translation import ugettext as _ @@ -10,7 +8,6 @@ from django.views.generic.base import TemplateResponseMixin from django.views.generic.edit import BaseCreateView, BaseDeleteView, BaseUpdateView from django.views.generic.list import BaseListView -from wagtail.utils.deprecation import RemovedInWagtail113Warning from wagtail.wagtailadmin import messages from wagtail.wagtailadmin.utils import permission_denied @@ -138,22 +135,6 @@ class EditView(PermissionCheckedMixin, TemplateResponseMixin, BaseUpdateView): success_message = None error_message = None - @property - def instance(self): - warnings.warn( - "instance attribute is deprecated, please use object instead", - category=RemovedInWagtail113Warning - ) - return self.object - - @instance.setter - def instance(self, instance): - warnings.warn( - "instance attribute is deprecated, please use object instead", - category=RemovedInWagtail113Warning - ) - self.object = instance - def get_object(self, queryset=None): if 'pk' not in self.kwargs: self.kwargs['pk'] = self.args[0] @@ -163,13 +144,13 @@ class EditView(PermissionCheckedMixin, TemplateResponseMixin, BaseUpdateView): return self.model.objects.all() def get_page_subtitle(self): - return str(self.instance) + return str(self.object) def get_edit_url(self): - return reverse(self.edit_url_name, args=(self.instance.id,)) + return reverse(self.edit_url_name, args=(self.object.id,)) def get_delete_url(self): - return reverse(self.delete_url_name, args=(self.instance.id,)) + return reverse(self.delete_url_name, args=(self.object.id,)) def get_success_url(self): return reverse(self.index_url_name) @@ -226,22 +207,6 @@ class DeleteView(PermissionCheckedMixin, TemplateResponseMixin, BaseDeleteView): permission_required = 'delete' success_message = None - @property - def instance(self): - warnings.warn( - "instance attribute is deprecated, please use object instead", - category=RemovedInWagtail113Warning - ) - return self.object - - @instance.setter - def instance(self, instance): - warnings.warn( - "instance attribute is deprecated, please use object instead", - category=RemovedInWagtail113Warning - ) - self.object = instance - def get_object(self, queryset=None): if 'pk' not in self.kwargs: self.kwargs['pk'] = self.args[0] @@ -254,30 +219,16 @@ class DeleteView(PermissionCheckedMixin, TemplateResponseMixin, BaseDeleteView): return self.model.objects.all() def get_page_subtitle(self): - return str(self.instance) + return str(self.object) def get_delete_url(self): - return reverse(self.delete_url_name, args=(self.instance.id,)) + return reverse(self.delete_url_name, args=(self.object.id,)) def get_success_message(self, instance): if self.success_message is None: return None return self.success_message.format(instance) - def get_context_data(self, **kwargs): - context = self.get_context() - if context: - warnings.warn( - "get_context() method is deprecated, please use get_context_data() instead", - category=RemovedInWagtail113Warning - ) - kwargs.update(context) - return super(DeleteView, self).get_context_data(**kwargs) - - def get_context(self): - # Deprecated, use get_context_data instead. - return {} - def delete(self, request, *args, **kwargs): response = super(DeleteView, self).delete(request, *args, **kwargs) messages.success(request, self.success_message.format(self.object))