Skip to content

Commit b1d1d50

Browse files
committed
Removed the translatable content get / set methods from CMSPlugin model
1 parent 967b838 commit b1d1d50

File tree

3 files changed

+1
-56
lines changed

3 files changed

+1
-56
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Removed the ``cms moderator`` command.
44
* Dropped Django < 1.11 support.
5+
* Removed the translatable content get / set methods from ``CMSPlugin`` model.
56

67

78
=== 3.5.2 (2018-04-11) ===

cms/models/pluginmodel.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from datetime import date
33
import json
4-
from operator import itemgetter
54
import os
65
import warnings
76

@@ -15,7 +14,6 @@
1514
from django.utils.six import text_type
1615
from django.utils.encoding import force_text, python_2_unicode_compatible
1716
from django.utils.safestring import mark_safe
18-
from django.utils.six.moves import filter
1917
from django.utils.translation import ugettext_lazy as _
2018

2119
from cms.exceptions import DontUsePageAttributeWarning
@@ -113,7 +111,6 @@ class CMSPlugin(six.with_metaclass(PluginModelBase, MP_Node)):
113111
creation_date = models.DateTimeField(_("creation date"), editable=False, default=timezone.now)
114112
changed_date = models.DateTimeField(auto_now=True)
115113
child_plugin_instances = None
116-
translatable_content_excluded_fields = []
117114

118115
class Meta:
119116
app_label = 'cms'
@@ -469,25 +466,6 @@ def notify_on_autoadd_children(self, request, conf, children):
469466
"""
470467
pass
471468

472-
def get_translatable_content(self):
473-
"""
474-
Returns {field_name: field_contents} for translatable fields, where
475-
field_contents > ''
476-
"""
477-
fields = (f for f in self._meta.fields
478-
if isinstance(f, (models.CharField, models.TextField)) and
479-
f.editable and not f.choices and
480-
f.name not in self.translatable_content_excluded_fields)
481-
return dict(filter(itemgetter(1),
482-
((f.name, getattr(self, f.name)) for f in fields)))
483-
484-
def set_translatable_content(self, fields):
485-
for field, value in fields.items():
486-
setattr(self, field, value)
487-
self.save()
488-
return all(getattr(self, field) == value
489-
for field, value in fields.items())
490-
491469
def delete(self, no_mp=False, *args, **kwargs):
492470
if no_mp:
493471
Model.delete(self, *args, **kwargs)

cms/tests/test_plugins.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,6 @@ def get_page(plugin):
903903
self.assertEqual(1, len(w))
904904
self.assertIn('test_plugins.py', w[0].filename)
905905

906-
def test_set_translatable_content(self):
907-
a = self.get_plugin_model('TextPlugin')(body="hello")
908-
self.assertTrue(a.set_translatable_content({'body': 'world'}))
909-
b = self.get_plugin_model('LinkPlugin')(name="hello")
910-
self.assertTrue(b.set_translatable_content({'name': 'world'}))
911-
912-
913906
def test_editing_plugin_changes_page_modification_time_in_sitemap(self):
914907
now = timezone.now()
915908
one_day_ago = now - datetime.timedelta(days=1)
@@ -1112,33 +1105,6 @@ def test_plugin_require_parent_from_object(self):
11121105
self.assertIn('ChildPlugin', child_classes)
11131106
self.assertIn('ParentPlugin', child_classes)
11141107

1115-
1116-
def test_plugin_translatable_content_getter_setter(self):
1117-
"""
1118-
Test that you can add a text plugin
1119-
"""
1120-
# add a new text plugin
1121-
page_data = self.get_new_page_data()
1122-
self.client.post(URL_CMS_PAGE_ADD, page_data)
1123-
page = Page.objects.drafts().first()
1124-
created_plugin_id = self._create_text_plugin_on_page(page)
1125-
1126-
# now edit the plugin
1127-
plugin = self._edit_text_plugin(created_plugin_id, "Hello World")
1128-
self.assertEqual("Hello World", plugin.body)
1129-
1130-
# see if the getter works
1131-
self.assertEqual({'body': "Hello World"}, plugin.get_translatable_content())
1132-
1133-
# change the content
1134-
self.assertEqual(True, plugin.set_translatable_content({'body': "It works!"}))
1135-
1136-
# check if it changed
1137-
self.assertEqual("It works!", plugin.body)
1138-
1139-
# double check through the getter
1140-
self.assertEqual({'body': "It works!"}, plugin.get_translatable_content())
1141-
11421108
def test_plugin_pool_register_returns_plugin_class(self):
11431109
@plugin_pool.register_plugin
11441110
class DecoratorTestPlugin(CMSPluginBase):

0 commit comments

Comments
 (0)