Skip to content

Commit

Permalink
Replace force_text with force_str (#546)
Browse files Browse the repository at this point in the history
* Bump to version 3.10.0

* replace all deprecated occurences of force_text with force_str

* replace all deprecated occurences of force_text with force_str

Co-authored-by: Jacob Rief <jacob.rief@uibk.ac.at>
  • Loading branch information
jrief and jrief authored Oct 19, 2020
1 parent 0aaa8ee commit 7d578cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions djangocms_text_ckeditor/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.template import RequestContext
from django.urls import re_path, reverse
from django.utils.decorators import method_decorator
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext
from django.views.decorators.clickjacking import xframe_options_sameorigin
from django.views.decorators.http import require_POST
Expand Down Expand Up @@ -339,7 +339,7 @@ def add_view(self, request, form_url='', extra_context=None):
# on GET request to the /add/ endpoint and so we bypass
# django's add_view, thus bypassing permission check.
message = gettext('You do not have permission to add a plugin.')
return HttpResponseForbidden(force_text(message))
return HttpResponseForbidden(force_str(message))

try:
# CMS 3.3 compatibility
Expand All @@ -358,7 +358,7 @@ def add_view(self, request, form_url='', extra_context=None):

except PermissionDenied:
message = gettext('You do not have permission to add a plugin.')
return HttpResponseForbidden(force_text(message))
return HttpResponseForbidden(force_str(message))
except ValidationError as error:
return HttpResponseBadRequest(error.message)

Expand Down Expand Up @@ -411,7 +411,7 @@ def _get_text_plugin_from_request(self, request, data):
if text_plugin_id:
return self._get_plugin_or_404(text_plugin_id)
message = gettext('Unable to process your request. Invalid token.')
raise ValidationError(message=force_text(message))
raise ValidationError(message=force_str(message))

@random_comment_exempt
@xframe_options_sameorigin
Expand Down Expand Up @@ -539,7 +539,7 @@ def save_model(self, request, obj, form, change):
obj.clean_plugins()

def get_action_token(self, request, obj):
plugin_id = force_text(obj.pk)
plugin_id = force_str(obj.pk)
# salt is different for every user
signer = signing.Signer(salt=request.session.session_key)
return signer.sign(plugin_id)
Expand Down
4 changes: 2 additions & 2 deletions djangocms_text_ckeditor/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import strip_tags
from django.utils.text import Truncator
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -51,7 +51,7 @@ def __str__(self):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.body = force_text(self.body)
self.body = force_str(self.body)

def clean(self):
self.body = plugin_tags_to_db(self.body)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.auth import get_permission_codename
from django.contrib.auth.models import Permission
from django.template import RequestContext
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import escape
from django.utils.http import urlencode, urlunquote

Expand Down Expand Up @@ -496,7 +496,7 @@ def test_render_child_plugin_endpoint(self):
admin=True,
)

self.assertEqual(force_text(response.content), rendered_child_plugin)
self.assertEqual(force_str(response.content), rendered_child_plugin)

child_plugin = self._add_child_plugin(text_plugin, plugin_type='PreviewDisabledPlugin')
text_plugin = self.add_plugin_to_text(text_plugin, child_plugin)
Expand All @@ -518,7 +518,7 @@ def test_render_child_plugin_endpoint(self):
'id="3"><span>Preview is disabled for this plugin</span>'
'</cms-plugin>')

self.assertEqual(force_text(response.content), rendered_child_plugin)
self.assertEqual(force_str(response.content), rendered_child_plugin)

def test_render_child_plugin_endpoint_calls_context_processors(self):
simple_page = create_page('test page', 'page.html', u'en')
Expand Down Expand Up @@ -554,7 +554,7 @@ def test_render_child_plugin_endpoint_calls_context_processors(self):
admin=True,
)

self.assertEqual(force_text(response.content), rendered_child_plugin)
self.assertEqual(force_str(response.content), rendered_child_plugin)

def test_render_child_plugin_permissions(self):
"""
Expand Down Expand Up @@ -614,7 +614,7 @@ def test_render_child_plugin_token_validation(self):
response = self.client.get(endpoint)

self.assertEqual(response.status_code, 400)
self.assertEqual(force_text(response.content), 'Unable to process your request. Invalid token.')
self.assertEqual(force_str(response.content), 'Unable to process your request. Invalid token.')

text_plugin_2 = add_plugin(
simple_placeholder,
Expand All @@ -634,7 +634,7 @@ def test_render_child_plugin_token_validation(self):
response = self.client.get(endpoint)

self.assertEqual(response.status_code, 400)
self.assertEqual(force_text(response.content), 'Unable to process your request.')
self.assertEqual(force_str(response.content), 'Unable to process your request.')

def test_custom_ckeditor_body_css_classes(self):
simple_page = create_page('test page', 'page.html', u'en')
Expand Down

0 comments on commit 7d578cd

Please sign in to comment.