Skip to content

Commit

Permalink
Feature/issue 648 unable to unlink (#649)
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

* fix #554: typo in Blockquote

* Pin to newer versions

* Attempt to increase the width of some drop-down menues

* fix #648: unable to unlink

* fix flake8 complains

* fix 1 failing unit test

* fix #648: unable to unlink

fix flake8 complains

fix 1 failing unit test

* fix: test suite for Django 2.2 (#650)

* fix django 2.2 tests

* Update dj22_cms37.txt

* Update dj22_cms38.txt

* Update dj22_cms40.txt

* Update dj31_cms38.txt

* Update settings.py

* Update frontend.yml

* Enable frontend tests

---------

Co-authored-by: Jacob Rief <[email protected]>
Co-authored-by: Fabian Braun <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2023
1 parent 3a4cf77 commit 4e5c4bd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
7 changes: 3 additions & 4 deletions djangocms_text_ckeditor/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,13 @@ def _get_text_plugin_from_request(self, request, data):
raise PermissionDenied

form = ActionTokenValidationForm(data)

if form.is_valid():
session_key = request.session.session_key
text_plugin_id = form.get_id_from_token(session_key)

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_str(message))

Expand All @@ -436,10 +436,9 @@ def render_plugin(self, request):
return HttpResponseBadRequest(error.message)

form = RenderPluginForm(request.GET, text_plugin=text_plugin)

if not form.is_valid():
message = gettext("Unable to process your request.")
return HttpResponseBadRequest(message)
# plugin not found, inform CKEDITOR.plugins.insertPlugin to remove it
return HttpResponse(status=204)

plugin_class = text_plugin.get_plugin_class_instance()
# The following is needed for permission checking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
.cke_dialog_body {
position: relative;
}
.cke_combo_text {
width: 100px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@
token: settings.action_token,
plugin: data.plugin_id
}
}).done(function (res) {
CMS.CKEditor.editors[editor.id].changed = true;
CMS.CKEditor.editors[editor.id].child_changed = true;
editor.insertHtml(res, 'unfiltered_html');
}).done(function (res, textStatus, jqXHR) {
CMS.CKEditor.editors[editor.id].changed = true;
CMS.CKEditor.editors[editor.id].child_changed = true;
if (jqXHR.status === 200) {
editor.insertHtml(res, 'unfiltered_html');
} else if (jqXHR.status === 204) {
editor.insertHtml(editor.getSelectedHtml().$.textContent);
}
editor.fire('updateSnapshot');
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
['HorizontalRule'],
['Link', 'Unlink'],
['NumberedList', 'BulletedList'],
['Outdent', 'Indent', '-', 'Blockqote', '-', 'Link', 'Unlink', '-', 'Table'],
['Outdent', 'Indent', '-', 'Blockquote', '-', 'Link', 'Unlink', '-', 'Table'],
['Source']
],

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion djangocms_text_ckeditor/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


# this path is changed automatically whenever you run `gulp bundle`
PATH_TO_JS = 'djangocms_text_ckeditor/js/dist/bundle-13948e6025.cms.ckeditor.min.js'
PATH_TO_JS = 'djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js'


class TextEditorWidget(forms.Textarea):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,8 @@ def test_render_child_plugin_token_validation(self):
endpoint += f'?token={action_token}&plugin={child_plugin.pk}'
response = self.client.get(endpoint)

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

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

0 comments on commit 4e5c4bd

Please sign in to comment.