mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Remove PageChooserPanel.target_content_type
This commit is contained in:
parent
69d86ac3f7
commit
498ced15fb
@ -2,11 +2,9 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import math
|
||||
import re
|
||||
import warnings
|
||||
|
||||
import django
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.forms.models import fields_for_model
|
||||
from django.template.loader import render_to_string
|
||||
@ -15,7 +13,6 @@ from django.utils.six import text_type
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
from wagtail.utils.decorators import cached_classmethod
|
||||
from wagtail.utils.deprecation import RemovedInWagtail17Warning
|
||||
from wagtail.wagtailadmin import widgets
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailcore.utils import camelcase_to_underscore, resolve_model_string
|
||||
@ -550,13 +547,6 @@ class BasePageChooserPanel(BaseChooserPanel):
|
||||
else:
|
||||
return [cls.model._meta.get_field(cls.field_name).rel.to]
|
||||
|
||||
@cached_classmethod
|
||||
def target_content_type(cls):
|
||||
warnings.warn(
|
||||
'{cls}.target_content_type() is deprecated. Use {cls}.target_models() instead'.format(cls=cls.__name__),
|
||||
category=RemovedInWagtail17Warning)
|
||||
return list(ContentType.objects.get_for_models(*cls.target_models()).values())
|
||||
|
||||
|
||||
class PageChooserPanel(object):
|
||||
def __init__(self, field_name, page_type=None, can_choose_root=False):
|
||||
|
@ -1,6 +1,5 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import warnings
|
||||
from datetime import date
|
||||
|
||||
import mock
|
||||
@ -13,7 +12,6 @@ from wagtail.tests.testapp.forms import ValidatedPageForm
|
||||
from wagtail.tests.testapp.models import (
|
||||
EventPage, EventPageChooserModel, EventPageSpeaker, PageChooserModel, SimplePage, ValidatedPage)
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.utils.deprecation import RemovedInWagtail17Warning
|
||||
from wagtail.wagtailadmin.edit_handlers import (
|
||||
FieldPanel, FieldRowPanel, InlinePanel, ObjectList, PageChooserPanel, RichTextFieldPanel,
|
||||
TabbedInterface, extract_panel_definitions_from_model_class, get_form_for_model)
|
||||
@ -664,46 +662,6 @@ class TestPageChooserPanel(TestCase):
|
||||
self.assertRaises(ImproperlyConfigured,
|
||||
result.target_models)
|
||||
|
||||
def test_target_content_type(self):
|
||||
with warnings.catch_warnings(record=True) as ws:
|
||||
warnings.simplefilter('always')
|
||||
|
||||
result = PageChooserPanel(
|
||||
'barbecue',
|
||||
'wagtailcore.site'
|
||||
).bind_to_model(PageChooserModel).target_content_type()[0]
|
||||
self.assertEqual(result.name, 'site')
|
||||
|
||||
self.assertEqual(len(ws), 1)
|
||||
self.assertIs(ws[0].category, RemovedInWagtail17Warning)
|
||||
|
||||
def test_target_content_type_malformed_type(self):
|
||||
with warnings.catch_warnings(record=True) as ws:
|
||||
warnings.simplefilter('always')
|
||||
|
||||
result = PageChooserPanel(
|
||||
'barbecue',
|
||||
'snowman'
|
||||
).bind_to_model(PageChooserModel)
|
||||
self.assertRaises(ImproperlyConfigured,
|
||||
result.target_content_type)
|
||||
|
||||
self.assertEqual(len(ws), 1)
|
||||
self.assertIs(ws[0].category, RemovedInWagtail17Warning)
|
||||
|
||||
def test_target_content_type_nonexistent_type(self):
|
||||
with warnings.catch_warnings(record=True) as ws:
|
||||
warnings.simplefilter('always')
|
||||
|
||||
result = PageChooserPanel(
|
||||
'barbecue',
|
||||
'snowman.lorry'
|
||||
).bind_to_model(PageChooserModel)
|
||||
self.assertRaises(ImproperlyConfigured,
|
||||
result.target_content_type)
|
||||
self.assertEqual(len(ws), 1)
|
||||
self.assertIs(ws[0].category, RemovedInWagtail17Warning)
|
||||
|
||||
|
||||
class TestInlinePanel(TestCase, WagtailTestUtils):
|
||||
fixtures = ['test.json']
|
||||
|
Loading…
Reference in New Issue
Block a user