diff --git a/wagtail/wagtailadmin/tests/test_widgets.py b/wagtail/wagtailadmin/tests/test_widgets.py index 7aee1ab0f7..8da3ea2a2f 100644 --- a/wagtail/wagtailadmin/tests/test_widgets.py +++ b/wagtail/wagtailadmin/tests/test_widgets.py @@ -1,12 +1,8 @@ from __future__ import absolute_import, unicode_literals -import warnings - -from django.contrib.contenttypes.models import ContentType from django.test import TestCase from wagtail.tests.testapp.models import EventPage, SimplePage -from wagtail.utils.deprecation import RemovedInWagtail17Warning from wagtail.wagtailadmin import widgets from wagtail.wagtailcore.models import Page @@ -70,30 +66,6 @@ class TestAdminPageChooserWidget(TestCase): js_init, "createPageChooser(\"test-id\", [\"tests.simplepage\", \"tests.eventpage\"], null, false);" ) - def test_render_js_init_with_content_type(self): - with warnings.catch_warnings(record=True) as ws: - warnings.simplefilter('always') - content_type = ContentType.objects.get_for_model(SimplePage) - widget = widgets.AdminPageChooser(content_type=content_type) - - self.assertEqual(len(ws), 1) - self.assertIs(ws[0].category, RemovedInWagtail17Warning) - self.assertEqual(widget.target_models, [SimplePage]) - - def test_render_js_init_with_multiple_content_types(self): - with warnings.catch_warnings(record=True) as ws: - warnings.simplefilter('always') - content_types = [ - # Not using get_for_models as we need deterministic ordering - ContentType.objects.get_for_model(SimplePage), - ContentType.objects.get_for_model(EventPage), - ] - widget = widgets.AdminPageChooser(content_type=content_types) - - self.assertEqual(len(ws), 1) - self.assertIs(ws[0].category, RemovedInWagtail17Warning) - self.assertEqual(widget.target_models, [SimplePage, EventPage]) - def test_render_js_init_with_can_choose_root(self): widget = widgets.AdminPageChooser(can_choose_root=True) diff --git a/wagtail/wagtailadmin/widgets.py b/wagtail/wagtailadmin/widgets.py index 30f6f9846d..f99ce1c721 100644 --- a/wagtail/wagtailadmin/widgets.py +++ b/wagtail/wagtailadmin/widgets.py @@ -2,22 +2,18 @@ from __future__ import absolute_import, unicode_literals import itertools import json -import warnings from functools import total_ordering -from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.forms import widgets from django.forms.utils import flatatt from django.template.loader import render_to_string from django.utils.encoding import python_2_unicode_compatible from django.utils.formats import get_format -from django.utils.functional import cached_property from django.utils.html import format_html from django.utils.translation import ugettext_lazy as _ from taggit.forms import TagWidget -from wagtail.utils.deprecation import RemovedInWagtail17Warning from wagtail.utils.widgets import WidgetWithScript from wagtail.wagtailcore import hooks from wagtail.wagtailcore.models import Page @@ -137,31 +133,12 @@ class AdminPageChooser(AdminChooser): choose_another_text = _('Choose another page') link_to_chosen_text = _('Edit this page') - def __init__(self, target_models=None, content_type=None, can_choose_root=False, **kwargs): + def __init__(self, target_models=None, can_choose_root=False, **kwargs): super(AdminPageChooser, self).__init__(**kwargs) self.target_models = list(target_models or [Page]) - - if content_type is not None: - if target_models is not None: - raise ValueError("Can not set both target_models and content_type") - warnings.warn( - 'The content_type argument for AdminPageChooser() is deprecated. Use the target_models argument instead', - category=RemovedInWagtail17Warning) - if isinstance(content_type, ContentType): - self.target_models = [content_type.model_class()] - else: - self.target_models = [ct.model_class() for ct in content_type] - self.can_choose_root = can_choose_root - @cached_property - def target_content_types(self): - warnings.warn( - 'AdminPageChooser.target_content_types is deprecated. Use AdminPageChooser.target_models instead', - category=RemovedInWagtail17Warning) - return list(ContentType.objects.get_for_models(*self.target_models).values()) - def _get_lowest_common_page_class(self): """ Return a Page class that is an ancestor for all Page classes in