From 77673d7bf89e60281cf0e79ee3bcab767b9a6f3f Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 23 Jul 2014 15:16:59 +0100 Subject: [PATCH] Replaced all DeprecationWarnngs with RemovedInWagtail06Warnings --- wagtail/wagtailadmin/hooks.py | 5 ++++- wagtail/wagtailadmin/templatetags/wagtailuserbar.py | 6 +++++- wagtail/wagtailadmin/views/pages.py | 4 +++- wagtail/wagtailcore/models.py | 10 ++++++---- wagtail/wagtailcore/templatetags/pageurl.py | 5 ++++- wagtail/wagtailcore/templatetags/rich_text.py | 5 ++++- wagtail/wagtailcore/tests/test_page_model.py | 6 ++++-- wagtail/wagtailcore/util.py | 5 ++++- wagtail/wagtailcore/views.py | 4 +++- wagtail/wagtailembeds/templatetags/embed_filters.py | 5 ++++- wagtail/wagtailimages/templatetags/image_tags.py | 5 ++++- wagtail/wagtailsearch/indexed.py | 4 +++- 12 files changed, 48 insertions(+), 16 deletions(-) diff --git a/wagtail/wagtailadmin/hooks.py b/wagtail/wagtailadmin/hooks.py index 989c43bd8..8c8a2374a 100644 --- a/wagtail/wagtailadmin/hooks.py +++ b/wagtail/wagtailadmin/hooks.py @@ -3,9 +3,12 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The wagtail.wagtailadmin.hooks module has been moved. " - "Use wagtail.wagtailcore.hooks instead.", DeprecationWarning) + "Use wagtail.wagtailcore.hooks instead.", RemovedInWagtail06Warning) from wagtail.wagtailcore.hooks import register, get_hooks diff --git a/wagtail/wagtailadmin/templatetags/wagtailuserbar.py b/wagtail/wagtailadmin/templatetags/wagtailuserbar.py index 3f1bf2951..c7861185e 100644 --- a/wagtail/wagtailadmin/templatetags/wagtailuserbar.py +++ b/wagtail/wagtailadmin/templatetags/wagtailuserbar.py @@ -3,16 +3,20 @@ import warnings from django import template from django.template.loader import render_to_string +from wagtail.utils.deprecation import RemovedInWagtail06Warning + from wagtail.wagtailcore.models import Page + register = template.Library() + @register.simple_tag(takes_context=True) def wagtailuserbar(context, css_path=None): if css_path is not None: warnings.warn( "Passing a CSS path to the wagtailuserbar tag is no longer required; use {% wagtailuserbar %} instead", - DeprecationWarning + RemovedInWagtail06Warning ) # Find request object diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 73b340854..8b61e29a0 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -12,6 +12,8 @@ from django.utils.translation import ugettext as _ from django.views.decorators.http import require_GET from django.views.decorators.vary import vary_on_headers +from wagtail.utils.deprecation import RemovedInWagtail06Warning + from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList from wagtail.wagtailadmin.forms import SearchForm from wagtail.wagtailadmin import tasks, signals @@ -429,7 +431,7 @@ def get_preview_response(page, preview_mode): if response: warnings.warn( "Defining 'show_as_mode' on a page model is deprecated. Use 'serve_preview' instead", - DeprecationWarning + RemovedInWagtail06Warning ) return response else: diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 1df870c38..a6d3c1f07 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -25,6 +25,8 @@ from django.utils.encoding import python_2_unicode_compatible from treebeard.mp_tree import MP_Node +from wagtail.utils.deprecation import RemovedInWagtail06Warning + from wagtail.wagtailcore.utils import camelcase_to_underscore from wagtail.wagtailcore.query import PageQuerySet from wagtail.wagtailcore.url_routing import RouteResult @@ -151,7 +153,7 @@ def get_leaf_page_content_type_ids(): get_leaf_page_content_type_ids is deprecated, as it treats pages without an explicit subpage_types setting as 'leaf' pages. Code that calls get_leaf_page_content_type_ids must be rewritten to avoid this incorrect assumption. - """, DeprecationWarning) + """, RemovedInWagtail06Warning) return [ content_type.id for content_type in get_page_types() @@ -163,7 +165,7 @@ def get_navigable_page_content_type_ids(): get_navigable_page_content_type_ids is deprecated, as it treats pages without an explicit subpage_types setting as 'leaf' pages. Code that calls get_navigable_page_content_type_ids must be rewritten to avoid this incorrect assumption. - """, DeprecationWarning) + """, RemovedInWagtail06Warning) return [ content_type.id for content_type in get_page_types() @@ -476,7 +478,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, indexed.Index def get_other_siblings(self): warnings.warn( "The 'Page.get_other_siblings()' method has been replaced. " - "Use 'Page.get_siblings(inclusive=False)' instead.", DeprecationWarning) + "Use 'Page.get_siblings(inclusive=False)' instead.", RemovedInWagtail06Warning) # get sibling pages excluding self return self.get_siblings().exclude(id=self.id) @@ -728,7 +730,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, indexed.Index modes = self.get_page_modes() if modes is not Page.DEFAULT_PREVIEW_MODES: # User has overriden get_page_modes instead of using preview_modes - warnings.warn("Overriding get_page_modes is deprecated. Define a preview_modes property instead", DeprecationWarning) + warnings.warn("Overriding get_page_modes is deprecated. Define a preview_modes property instead", RemovedInWagtail06Warning) return modes diff --git a/wagtail/wagtailcore/templatetags/pageurl.py b/wagtail/wagtailcore/templatetags/pageurl.py index 63d2eb45e..016a77759 100644 --- a/wagtail/wagtailcore/templatetags/pageurl.py +++ b/wagtail/wagtailcore/templatetags/pageurl.py @@ -1,8 +1,11 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The pageurl tag library has been moved to wagtailcore_tags. " - "Use {% load wagtailcore_tags %} instead.", DeprecationWarning) + "Use {% load wagtailcore_tags %} instead.", RemovedInWagtail06Warning) from wagtail.wagtailcore.templatetags.wagtailcore_tags import register, pageurl diff --git a/wagtail/wagtailcore/templatetags/rich_text.py b/wagtail/wagtailcore/templatetags/rich_text.py index c1db48250..09e93d846 100644 --- a/wagtail/wagtailcore/templatetags/rich_text.py +++ b/wagtail/wagtailcore/templatetags/rich_text.py @@ -1,8 +1,11 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The rich_text tag library has been moved to wagtailcore_tags. " - "Use {% load wagtailcore_tags %} instead.", DeprecationWarning) + "Use {% load wagtailcore_tags %} instead.", RemovedInWagtail06Warning) from wagtail.wagtailcore.templatetags.wagtailcore_tags import register, richtext diff --git a/wagtail/wagtailcore/tests/test_page_model.py b/wagtail/wagtailcore/tests/test_page_model.py index af12fa705..8a542d594 100644 --- a/wagtail/wagtailcore/tests/test_page_model.py +++ b/wagtail/wagtailcore/tests/test_page_model.py @@ -3,6 +3,8 @@ import warnings from django.test import TestCase, Client from django.http import HttpRequest, Http404 +from wagtail.utils.deprecation import RemovedInWagtail06Warning + from wagtail.wagtailcore.models import Page, Site from wagtail.tests.models import EventPage, EventIndex, SimplePage, PageWithOldStyleRouteMethod @@ -240,9 +242,9 @@ class TestServeView(TestCase): with warnings.catch_warnings(record=True) as w: response = self.client.get('/old-style-route/') - # Check that a DeprecationWarning has been triggered + # Check that a RemovedInWagtail06Warning has been triggered self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + self.assertTrue(issubclass(w[-1].category, RemovedInWagtail06Warning)) self.assertTrue("Page.route should return an instance of wagtailcore.url_routing.RouteResult" in str(w[-1].message)) expected_page = PageWithOldStyleRouteMethod.objects.get(url_path='/home/old-style-route/') diff --git a/wagtail/wagtailcore/util.py b/wagtail/wagtailcore/util.py index 842fe24fa..7bbe82f57 100644 --- a/wagtail/wagtailcore/util.py +++ b/wagtail/wagtailcore/util.py @@ -1,7 +1,10 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The wagtail.wagtailcore.util module has been renamed. " - "Use wagtail.wagtailcore.utils instead.", DeprecationWarning) + "Use wagtail.wagtailcore.utils instead.", RemovedInWagtail06Warning) from .utils import * diff --git a/wagtail/wagtailcore/views.py b/wagtail/wagtailcore/views.py index b955efa54..5daa642b9 100644 --- a/wagtail/wagtailcore/views.py +++ b/wagtail/wagtailcore/views.py @@ -5,6 +5,8 @@ from django.shortcuts import get_object_or_404, redirect from django.core.urlresolvers import reverse from django.conf import settings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + from wagtail.wagtailcore import hooks from wagtail.wagtailcore.models import Page, PageViewRestriction from wagtail.wagtailcore.forms import PasswordPageViewRestrictionForm @@ -21,7 +23,7 @@ def serve(request, path): if isinstance(route_result, HttpResponse): warnings.warn( "Page.route should return an instance of wagtailcore.url_routing.RouteResult, not an HttpResponse", - DeprecationWarning + RemovedInWagtail06Warning ) return route_result diff --git a/wagtail/wagtailembeds/templatetags/embed_filters.py b/wagtail/wagtailembeds/templatetags/embed_filters.py index f6690611b..1eef037e8 100644 --- a/wagtail/wagtailembeds/templatetags/embed_filters.py +++ b/wagtail/wagtailembeds/templatetags/embed_filters.py @@ -1,8 +1,11 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The embed_filters tag library has been moved to wagtailembeds_tags. " - "Use {% load wagtailembeds_tags %} instead.", DeprecationWarning) + "Use {% load wagtailembeds_tags %} instead.", RemovedInWagtail06Warning) from wagtail.wagtailembeds.templatetags.wagtailembeds_tags import register, embed diff --git a/wagtail/wagtailimages/templatetags/image_tags.py b/wagtail/wagtailimages/templatetags/image_tags.py index c26729f6c..00e59aca0 100644 --- a/wagtail/wagtailimages/templatetags/image_tags.py +++ b/wagtail/wagtailimages/templatetags/image_tags.py @@ -1,8 +1,11 @@ import warnings +from wagtail.utils.deprecation import RemovedInWagtail06Warning + + warnings.warn( "The image_tags tag library has been moved to wagtailimages_tags. " - "Use {% load wagtailimages_tags %} instead.", DeprecationWarning) + "Use {% load wagtailimages_tags %} instead.", RemovedInWagtail06Warning) from wagtail.wagtailimages.templatetags.wagtailimages_tags import register, image diff --git a/wagtail/wagtailsearch/indexed.py b/wagtail/wagtailsearch/indexed.py index 2e506d690..e775ff5c7 100644 --- a/wagtail/wagtailsearch/indexed.py +++ b/wagtail/wagtailsearch/indexed.py @@ -4,6 +4,8 @@ from six import string_types from django.db import models +from wagtail.utils.deprecation import RemovedInWagtail06Warning + class Indexed(object): @classmethod @@ -77,7 +79,7 @@ class Indexed(object): # Display deprecation warning if indexed_fields has been used if indexed_fields: warnings.warn("'indexed_fields' setting is now deprecated." - "Use 'search_fields' instead.", DeprecationWarning) + "Use 'search_fields' instead.", RemovedInWagtail06Warning) # Convert them into search fields for field_name, _config in indexed_fields.items():