Remove deprecated features for 1.5; update deprecation warning versions

This commit is contained in:
Matt Westcott 2016-03-11 12:10:45 +00:00 committed by Karl Hobley
parent e001cac581
commit 959d72c30c
3 changed files with 3 additions and 122 deletions

View file

@ -1,9 +1,9 @@
class RemovedInWagtail15Warning(DeprecationWarning):
class RemovedInWagtail16Warning(DeprecationWarning):
pass
removed_in_next_version_warning = RemovedInWagtail15Warning
removed_in_next_version_warning = RemovedInWagtail16Warning
class RemovedInWagtail16Warning(PendingDeprecationWarning):
class RemovedInWagtail17Warning(PendingDeprecationWarning):
pass

View file

@ -2,7 +2,6 @@ from __future__ import unicode_literals
import json
import logging
import warnings
from collections import defaultdict
from django.conf import settings
@ -31,7 +30,6 @@ from django.utils.translation import ugettext_lazy as _
from modelcluster.models import ClusterableModel, get_all_child_relations
from treebeard.mp_tree import MP_Node
from wagtail.utils.deprecation import RemovedInWagtail15Warning
from wagtail.wagtailcore.query import PageQuerySet, TreeQuerySet
from wagtail.wagtailcore.signals import page_published, page_unpublished
from wagtail.wagtailcore.url_routing import RouteResult
@ -190,13 +188,6 @@ def clear_site_root_paths_on_delete(sender, instance, **kwargs):
PAGE_MODEL_CLASSES = []
def get_content_type_list(models):
"""
Helper function to return a list of content types, given a list of models
"""
return ContentType.objects.get_for_models(*models).values()
def get_page_models():
"""
Returns a list of all non-abstract Page model classes defined in this project.
@ -212,19 +203,6 @@ def get_default_page_content_type():
return ContentType.objects.get_for_model(Page)
def get_page_types():
"""
DEPRECATED.
Returns a list of ContentType objects for all non-abstract Page model classes
defined in this project.
"""
warnings.warn(
"get_page_types is deprecated - please use get_page_models instead",
RemovedInWagtail15Warning, stacklevel=2)
return get_content_type_list(PAGE_MODEL_CLASSES)
class BasePageManager(models.Manager):
def get_queryset(self):
return PageQuerySet(self.model).order_by('path')
@ -870,18 +848,6 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
return cls._clean_subpage_models
@classmethod
def clean_subpage_types(cls):
"""
DEPRECATED.
Returns the list of subpage types, normalised as ContentType objects
"""
warnings.warn(
"clean_subpage_types is deprecated - please use clean_subpage_models instead",
RemovedInWagtail15Warning, stacklevel=2)
return get_content_type_list(cls.clean_subpage_models())
@classmethod
def clean_parent_page_models(cls):
"""
@ -907,18 +873,6 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
return cls._clean_parent_page_models
@classmethod
def clean_parent_page_types(cls):
"""
DEPRECATED.
Returns the list of parent page types, normalised as ContentType objects
"""
warnings.warn(
"clean_parent_page_types is deprecated - please use clean_parent_page_models instead",
RemovedInWagtail15Warning, stacklevel=2)
return get_content_type_list(cls.clean_parent_page_models())
@classmethod
def allowed_parent_page_models(cls):
"""
@ -930,19 +884,6 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
if cls in parent_model.clean_subpage_models()
]
@classmethod
def allowed_parent_page_types(cls):
"""
DEPRECATED.
Returns the list of page types that this page type can be a subpage of,
as a list of ContentType objects
"""
warnings.warn(
"allowed_parent_page_types is deprecated - please use allowed_parent_page_models instead",
RemovedInWagtail15Warning, stacklevel=2)
return get_content_type_list(cls.allowed_parent_page_models())
@classmethod
def allowed_subpage_models(cls):
"""
@ -954,19 +895,6 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
if cls in subpage_model.clean_parent_page_models()
]
@classmethod
def allowed_subpage_types(cls):
"""
DEPRECATED.
Returns the list of page types that this page type can have as subpages,
as a list of ContentType objects
"""
warnings.warn(
"allowed_subpage_types is deprecated - please use allowed_subpage_models instead",
RemovedInWagtail15Warning, stacklevel=2)
return get_content_type_list(cls.allowed_subpage_models())
@classmethod
def creatable_subpage_models(cls):
"""

View file

@ -896,31 +896,6 @@ class TestSubpageTypeBusinessRules(TestCase, WagtailTestUtils):
self.assertNotIn(SimplePage, BusinessSubIndex.allowed_subpage_models())
self.assertIn(BusinessChild, BusinessSubIndex.allowed_subpage_models())
def test_allowed_subpage_types(self):
"""
Same assertions as for test_allowed_subpage_models -
allowed_subpage_types should mirror allowed_subpage_models with ContentType
objects rather than model classes
"""
with self.ignore_deprecation_warnings():
# SimplePage does not define any restrictions on subpage types
# SimplePage is a valid subpage of SimplePage
self.assertIn(get_ct(SimplePage), SimplePage.allowed_subpage_types())
# BusinessIndex is a valid subpage of SimplePage
self.assertIn(get_ct(BusinessIndex), SimplePage.allowed_subpage_types())
# BusinessSubIndex is not valid, because it explicitly omits SimplePage from parent_page_types
self.assertNotIn(get_ct(BusinessSubIndex), SimplePage.allowed_subpage_types())
# BusinessChild has an empty subpage_types list, so does not allow anything
self.assertNotIn(get_ct(SimplePage), BusinessChild.allowed_subpage_types())
self.assertNotIn(get_ct(BusinessIndex), BusinessChild.allowed_subpage_types())
self.assertNotIn(get_ct(BusinessSubIndex), BusinessChild.allowed_subpage_types())
# BusinessSubIndex only allows BusinessChild as subpage type
self.assertNotIn(get_ct(SimplePage), BusinessSubIndex.allowed_subpage_types())
self.assertIn(get_ct(BusinessChild), BusinessSubIndex.allowed_subpage_types())
def test_allowed_parent_page_models(self):
# SimplePage does not define any restrictions on parent page types
# SimplePage is a valid parent page of SimplePage
@ -936,28 +911,6 @@ class TestSubpageTypeBusinessRules(TestCase, WagtailTestUtils):
self.assertNotIn(SimplePage, BusinessSubIndex.allowed_parent_page_models())
self.assertIn(BusinessIndex, BusinessSubIndex.allowed_parent_page_models())
def test_allowed_parent_page_types(self):
"""
Same assertions as for test_allowed_parent_page_models -
allowed_parent_page_types should mirror allowed_parent_page_models
with ContentType objects rather than model classes
"""
with self.ignore_deprecation_warnings():
# SimplePage does not define any restrictions on parent page types
# SimplePage is a valid parent page of SimplePage
self.assertIn(get_ct(SimplePage), SimplePage.allowed_parent_page_types())
# BusinessChild cannot be a parent of anything
self.assertNotIn(get_ct(BusinessChild), SimplePage.allowed_parent_page_types())
# BusinessNowherePage does not allow anything as a parent
self.assertNotIn(get_ct(SimplePage), BusinessNowherePage.allowed_parent_page_types())
self.assertNotIn(get_ct(StandardIndex), BusinessNowherePage.allowed_parent_page_types())
# BusinessSubIndex only allows BusinessIndex as a parent
self.assertNotIn(get_ct(SimplePage), BusinessSubIndex.allowed_parent_page_types())
self.assertIn(get_ct(BusinessIndex), BusinessSubIndex.allowed_parent_page_types())
def test_can_exist_under(self):
self.assertTrue(SimplePage.can_exist_under(SimplePage()))