Skip to content

Commit

Permalink
fix #648: unable to unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Sep 20, 2023
1 parent eb1e8c8 commit 9fe48f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 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 @@ -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
Loading

0 comments on commit 9fe48f3

Please sign in to comment.