Skip to content

Commit d0b78a9

Browse files
committed
Merge pull request django-cms#3570 from yakky/feature/remove_deprecations
Remove deprecated methods / function
2 parents 71f000d + 2e0e236 commit d0b78a9

File tree

10 files changed

+19
-221
lines changed

10 files changed

+19
-221
lines changed

cms/admin/placeholderadmin.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
import json
3+
24
from cms.models.placeholderpluginmodel import PlaceholderReference
35
from cms.utils.urlutils import admin_reverse
46
from django.contrib.admin.helpers import AdminForm
57
from django.utils.decorators import method_decorator
6-
import json
78

89
from django.views.decorators.clickjacking import xframe_options_sameorigin
910
from cms.constants import PLUGIN_COPY_ACTION, PLUGIN_MOVE_ACTION
@@ -14,15 +15,13 @@
1415
from cms.utils import get_cms_setting
1516
from cms.utils.compat.dj import force_unicode
1617
from cms.utils.plugins import requires_reload, has_reached_plugin_limit
17-
from django.contrib.admin import ModelAdmin
1818
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden
1919
from django.shortcuts import render_to_response, get_object_or_404
2020
from django.template import RequestContext
2121
from django.template.defaultfilters import force_escape, escapejs
2222
from django.utils.translation import ugettext as _
2323
from django.conf import settings
2424
from django.views.decorators.http import require_POST
25-
import warnings
2625
from django.template.response import TemplateResponse
2726

2827
from django.contrib.admin.util import get_deleted_objects
@@ -559,16 +558,3 @@ def clear_placeholder(self, request, placeholder_id):
559558
return TemplateResponse(request, "admin/cms/page/plugin/delete_confirmation.html", context,
560559
current_app=self.admin_site.name)
561560

562-
563-
class PlaceholderAdmin(PlaceholderAdminMixin, ModelAdmin):
564-
def __init__(self, *args, **kwargs):
565-
warnings.warn("Class PlaceholderAdmin is deprecated and will be removed in 3.1. "
566-
"Instead, combine PlaceholderAdminMixin with admin.ModelAdmin.", DeprecationWarning)
567-
super(PlaceholderAdmin, self).__init__(*args, **kwargs)
568-
569-
570-
class FrontendEditableAdmin(FrontendEditableAdminMixin):
571-
def __init__(self, *args, **kwargs):
572-
warnings.warn("Class FrontendEditableAdmin is deprecated and will be removed in 3.1. "
573-
"Instead, use FrontendEditableAdminMixin.", DeprecationWarning)
574-
super(FrontendEditableAdmin, self).__init__(*args, **kwargs)

cms/context_processors.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from cms.utils.conf import get_cms_setting
33
from cms.utils import get_template_from_request
4-
import warnings
4+
55

66
def cms_settings(request):
77
"""
@@ -12,10 +12,3 @@ def cms_settings(request):
1212
'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'),
1313
'CMS_TEMPLATE': lambda: get_template_from_request(request),
1414
}
15-
16-
17-
def media(request):
18-
warnings.warn('cms.context_processors.media has been deprecated in favor of '
19-
'cms.context_processors.cms_settings. Please update your '
20-
'configuration', DeprecationWarning)
21-
return cms_settings(request)

cms/plugin_pool.py

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# -*- coding: utf-8 -*-
2-
import warnings
3-
42
from django.core.exceptions import ImproperlyConfigured
53
from django.conf.urls import url, patterns, include
64
from django.contrib.formtools.wizard.views import normalize_name
7-
from django.db import connection
85
from django.db.models import signals
9-
from django.db.models.fields.related import ManyToManyField
10-
from django.db.models.fields.related import ReverseManyRelatedObjectsDescriptor
116
from django.template.defaultfilters import slugify
127
from django.utils import six
138
from django.utils.translation import get_language, deactivate_all, activate
@@ -16,7 +11,7 @@
1611
from cms.exceptions import PluginAlreadyRegistered, PluginNotRegistered
1712
from cms.plugin_base import CMSPluginBase
1813
from cms.models import CMSPlugin
19-
from cms.utils.django_load import load, get_subclasses
14+
from cms.utils.django_load import load
2015
from cms.utils.helpers import reversion_register
2116
from cms.utils.placeholder import get_placeholder_conf
2217
from cms.utils.compat.dj import force_unicode, is_installed
@@ -151,66 +146,6 @@ def set_plugin_meta(self):
151146
"""
152147
if self.patched:
153148
return
154-
table_names = connection.introspection.table_names()
155-
subs = get_subclasses(CMSPlugin)
156-
for model in subs:
157-
if not model._meta.abstract:
158-
159-
splitter = '%s_' % model._meta.app_label
160-
table_name = model._meta.db_table
161-
162-
#
163-
# Checks to see if this plugin's model's table's name is
164-
# properly named with the app_label as the prefix (not
165-
# 'cmsplugin')
166-
#
167-
if (table_name not in table_names and splitter in table_name):
168-
proper_table_name = table_name
169-
splitted = table_name.split(splitter, 1)
170-
bad_table_name = 'cmsplugin_%s' % splitted[1]
171-
if bad_table_name in table_names:
172-
model._meta.db_table = bad_table_name
173-
warnings.warn(
174-
'please rename the table "%s" to "%s" in %s\nThe compatibility code will be removed in 3.1' % (
175-
bad_table_name, proper_table_name, model._meta.app_label), DeprecationWarning)
176-
177-
for att_name in model.__dict__.keys():
178-
att = model.__dict__[att_name]
179-
180-
#
181-
# Checks to see if this plugin's model contains an M2M
182-
# field, whose 'through' table is properly named with the
183-
# app_label as the prefix (and not 'cmsplugin')
184-
#
185-
if isinstance(att, ManyToManyField):
186-
table_name = att.rel.through._meta.db_table
187-
if (table_name not in table_names and splitter in table_name):
188-
proper_table_name = table_name
189-
splitted = proper_table_name.split(splitter, 1)
190-
bad_table_name = 'cmsplugin_%s' % splitted[1]
191-
if bad_table_name in table_names:
192-
att.rel.through._meta.db_table = bad_table_name
193-
warnings.warn(
194-
'please rename the table "%s" to "%s" in %s\nThe compatibility code will be removed in 3.1' % (
195-
bad_table_name, proper_table_name, model._meta.app_label), DeprecationWarning)
196-
197-
#
198-
# Checks to see if this plugin's model contains an M2M
199-
# field, whose 'through' table is properly named with the
200-
# app_label as the prefix (and not 'cmsplugin')
201-
#
202-
elif isinstance(att, ReverseManyRelatedObjectsDescriptor):
203-
table_name = att.through._meta.db_table
204-
if (table_name not in table_names and splitter in table_name):
205-
proper_table_name = table_name
206-
splitted = proper_table_name.split(splitter, 1)
207-
bad_table_name = 'cmsplugin_%s' % splitted[1]
208-
if bad_table_name in table_names:
209-
att.through._meta.db_table = bad_table_name
210-
warnings.warn(
211-
'please rename the table "%s" to "%s" in %s\nThe compatibility code will be removed in 3.1' % (
212-
bad_table_name, proper_table_name, model._meta.app_label), DeprecationWarning)
213-
214149
self.patched = True
215150

216151
def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins", include_page_only=True):

cms/templatetags/placeholder_tags.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

cms/tests/check.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import unittest
55

6-
from djangocms_text_ckeditor.cms_plugins import TextPlugin
6+
from django.core.exceptions import ImproperlyConfigured
77
from django.template import TemplateSyntaxError, base
88
from django.test import TestCase
99

@@ -15,6 +15,7 @@
1515
from cms.test_utils.util.context_managers import SettingsOverride
1616
from cms.utils.check import FileOutputWrapper, check, FileSectionWrapper
1717
from cms.utils.compat import DJANGO_1_6
18+
from djangocms_text_ckeditor.cms_plugins import TextPlugin
1819

1920

2021
class TestOutput(FileOutputWrapper):
@@ -90,7 +91,7 @@ def test_no_sekizai_template_context_processor(self):
9091

9192
def test_old_style_i18n_settings(self):
9293
with SettingsOverride(CMS_LANGUAGES=[('en', 'English')]):
93-
self.assertCheck(True, warnings=1, errors=0)
94+
self.assertRaises(ImproperlyConfigured, self.assertCheck, True, warnings=1, errors=0)
9495

9596
def test_cms_hide_untranslated_deprecated(self):
9697
with SettingsOverride(CMS_HIDE_UNTRANSLATED=True):

cms/tests/menu_utils.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from cms.test_utils.testcases import CMSTestCase
44
from cms.test_utils.util.mock import AttributeObject
55
from menus.templatetags.menu_tags import PageLanguageUrl
6-
from menus.utils import (simple_language_changer, find_selected,
7-
language_changer_decorator)
6+
from menus.utils import find_selected, language_changer_decorator
87

98

109
class DumbPageLanguageUrl(PageLanguageUrl):
@@ -27,23 +26,6 @@ def test_reverse_in_changer(self):
2726
response = self.client.get('/en/sample/login3/')
2827
self.assertContains(response, '<h1>/fr/sample/login3/</h1>')
2928

30-
def test_simple_language_changer(self):
31-
func = self.get_simple_view()
32-
decorated_view = simple_language_changer(func)
33-
# check we maintain the view name
34-
self.assertEqual(func.__name__, decorated_view.__name__)
35-
request = self.get_request('/', 'en')
36-
response = decorated_view(request)
37-
self.assertEqual(response.content, b'')
38-
fake_context = {'request': request}
39-
tag = DumbPageLanguageUrl()
40-
output = tag.get_context(fake_context, 'en')
41-
url = output['content']
42-
self.assertEqual(url, '/en/')
43-
output = tag.get_context(fake_context, 'ja')
44-
url = output['content']
45-
self.assertEqual(url, '/ja/')
46-
4729
def test_default_language_changer(self):
4830
view = self.get_simple_view()
4931
# check we maintain the view name

cms/tests/placeholder.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import with_statement
33
import itertools
4-
import warnings
54

65
from django.conf import settings
76
from django.contrib import admin
@@ -23,7 +22,6 @@
2322
from sekizai.context import SekizaiContext
2423

2524
from cms import constants
26-
from cms.admin.placeholderadmin import PlaceholderAdmin, PlaceholderAdminMixin
2725
from cms.api import add_plugin, create_page, create_title
2826
from cms.exceptions import DuplicatePlaceholderWarning
2927
from cms.models.fields import PlaceholderField
@@ -654,17 +652,6 @@ def test_placeholder_languages_page(self):
654652
langs = [lang['code'] for lang in placeholder.get_filled_languages()]
655653
self.assertEqual(avail_langs, set(langs))
656654

657-
def test_deprecated_PlaceholderAdmin(self):
658-
admin_site = admin.sites.AdminSite()
659-
with warnings.catch_warnings(record=True) as w:
660-
warnings.simplefilter("always")
661-
pa = PlaceholderAdmin(Placeholder, admin_site)
662-
self.assertEqual(len(w), 1)
663-
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
664-
self.assertTrue("PlaceholderAdminMixin with admin.ModelAdmin" in str(w[-1].message))
665-
self.assertIsInstance(pa, admin.ModelAdmin, 'PlaceholderAdmin not admin.ModelAdmin')
666-
self.assertIsInstance(pa, PlaceholderAdminMixin, 'PlaceholderAdmin not PlaceholderAdminMixin')
667-
668655
@override_settings(TEMPLATE_LOADERS=(
669656
('django.template.loaders.cached.Loader', (
670657
'django.template.loaders.filesystem.Loader',

cms/utils/conf.py

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
# -*- coding: utf-8 -*-
22
from functools import update_wrapper
33
import os
4-
import pprint
5-
import warnings
64

75
from django.conf import settings
86
from django.core.exceptions import ImproperlyConfigured
97
from django.utils import six
108
from django.utils.translation import ugettext_lazy as _
119

1210
from cms import constants
13-
from cms.exceptions import CMSDeprecationWarning
1411
from cms.utils.compat.urls import urljoin
1512

1613

1714
__all__ = ['get_cms_setting']
1815

1916

20-
class VERIFIED: pass # need a unique identifier for CMS_LANGUAGES
17+
class VERIFIED: pass # need a unique identifier for CMS_LANGUAGES
2118

2219

2320
def default(name):
@@ -140,11 +137,16 @@ def get_templates():
140137
return templates
141138

142139

143-
def _ensure_languages_settings_new(languages):
140+
def _ensure_languages_settings(languages):
144141
valid_language_keys = ['code', 'name', 'fallbacks', 'hide_untranslated', 'redirect_on_fallback', 'public']
145142
required_language_keys = ['code', 'name']
146143
simple_defaults = ['public', 'redirect_on_fallback', 'hide_untranslated']
147144

145+
if not isinstance(languages, dict):
146+
raise ImproperlyConfigured(
147+
"CMS_LANGUAGES must be a dictionary with site IDs and 'default'"
148+
" as keys. Please check the format.")
149+
148150
defaults = languages.pop('default', {})
149151
default_fallbacks = defaults.get('fallbacks')
150152
needs_fallbacks = []
@@ -192,61 +194,11 @@ def _ensure_languages_settings_new(languages):
192194
lang_code != language_object['code']]
193195

194196
languages['default'] = defaults
197+
languages[VERIFIED] = True # this will be busted by SettingsOverride and cause a re-check
195198

196199
return languages
197200

198201

199-
def _get_old_language_conf(code, name, template): # pragma: no cover
200-
language = template.copy()
201-
language['code'] = code
202-
language['name'] = name
203-
default_fallbacks = dict(settings.CMS_LANGUAGES).keys()
204-
if hasattr(settings, 'CMS_LANGUAGE_FALLBACK'):
205-
if settings.CMS_LANGUAGE_FALLBACK:
206-
if hasattr(settings, 'CMS_LANGUAGE_CONF'):
207-
language['fallbacks'] = settings.CMS_LANGUAGE_CONF.get(code, default_fallbacks)
208-
else:
209-
language['fallbacks'] = default_fallbacks
210-
else:
211-
language['fallbacks'] = []
212-
else:
213-
if hasattr(settings, 'CMS_LANGUAGE_CONF'):
214-
language['fallbacks'] = settings.CMS_LANGUAGE_CONF.get(code, default_fallbacks)
215-
else:
216-
language['fallbacks'] = default_fallbacks
217-
if hasattr(settings, 'CMS_FRONTEND_LANGUAGES'):
218-
language['public'] = code in settings.CMS_FRONTEND_LANGUAGES
219-
return language
220-
221-
222-
def _translate_legacy_languages_settings(languages):
223-
new_languages = {}
224-
lang_template = {'fallbacks': [], 'public': True, 'redirect_on_fallback': True,
225-
'hide_untranslated': getattr(settings, 'CMS_HIDE_UNTRANSLATED', False)}
226-
codes = dict(languages)
227-
for site, site_languages in getattr(settings, 'CMS_SITE_LANGUAGES', {1: languages}).items():
228-
new_languages[site] = []
229-
for site_language in site_languages:
230-
if site_language in codes:
231-
new_languages[site].append(_get_old_language_conf(site_language, codes[site_language], lang_template))
232-
233-
pp = pprint.PrettyPrinter(indent=4)
234-
warnings.warn("CMS_LANGUAGES has changed in django-cms 2.4\n"
235-
"You may replace CMS_LANGUAGES with the following:\n%s" % pp.pformat(new_languages),
236-
CMSDeprecationWarning)
237-
new_languages['default'] = lang_template.copy()
238-
return new_languages
239-
240-
241-
def _ensure_languages_settings(languages):
242-
if isinstance(languages, dict):
243-
verified_languages = _ensure_languages_settings_new(languages)
244-
else:
245-
verified_languages = _translate_legacy_languages_settings(languages)
246-
verified_languages[VERIFIED] = True # this will be busted by SettingsOverride and cause a re-check
247-
return verified_languages
248-
249-
250202
def get_languages():
251203
if not isinstance(settings.SITE_ID, six.integer_types):
252204
raise ImproperlyConfigured(
@@ -255,10 +207,10 @@ def get_languages():
255207
if not settings.USE_I18N:
256208
return _ensure_languages_settings(
257209
{settings.SITE_ID: [{'code': settings.LANGUAGE_CODE, 'name': settings.LANGUAGE_CODE}]})
258-
if not settings.LANGUAGE_CODE in dict(settings.LANGUAGES):
210+
if settings.LANGUAGE_CODE not in dict(settings.LANGUAGES):
259211
raise ImproperlyConfigured(
260-
'LANGUAGE_CODE "%s" must have a matching entry in LANGUAGES' % settings.LANGUAGE_CODE
261-
)
212+
'LANGUAGE_CODE "%s" must have a matching entry in LANGUAGES' % settings.LANGUAGE_CODE
213+
)
262214
languages = getattr(settings, 'CMS_LANGUAGES', {
263215
settings.SITE_ID: [{'code': code, 'name': _(name)} for code, name in settings.LANGUAGES]
264216
})

0 commit comments

Comments
 (0)