Horst Gutmann committed 9ce9149

This should fix the wymeditor integration and extend it to the excerpt.

  • Participants
  • Parent commits 6ddd267

Comments (0)

Files changed (3)

File cmsplugin_news/

+from __future__ import absolute_import
 from django import forms
 from django.conf import settings
 from cms.plugin_pool import plugin_pool
 from cms.plugins.text.settings import USE_TINYMCE
-from cmsplugin_news.widgets.wymeditor_widget import WYMEditor
+from .widgets.wymeditor_widget import WYMEditor
+from .models import News
-from cmsplugin_news.models import News
 class NewsForm(forms.ModelForm):
     class Meta:
         model = News
     def _get_widget(self):
-        plugins = plugin_pool.get_text_enabled_plugins(placeholder=None, page=None)
+        plugins = plugin_pool.get_text_enabled_plugins(placeholder=None,
+                page=None)
         if USE_TINYMCE and "tinymce" in settings.INSTALLED_APPS:
             from cmsplugin_news.widgets.tinymce_widget import TinyMCEEditor
             return TinyMCEEditor(installed_plugins=plugins)
             return WYMEditor(installed_plugins=plugins)
     def __init__(self, *args, **kwargs):
         super(NewsForm, self).__init__(*args, **kwargs)
         widget = self._get_widget()
+        self.fields['excerpt'].widget = widget
         self.fields['content'].widget = widget

File cmsplugin_news/templates/cmsplugin_news/widgets/wymeditor.html

-    $('#id_{{ name }}').wymeditor({
+    jQuery('#id_{{ name }}').wymeditor({
         lang: '{{ language }}',
         skin: 'django',
-        skinPath: "{{ CMS_MEDIA_URL }}js/wymeditor/skins/django/",
+        skinPath: "{{ STATIC_URL }}cms/js/wymeditor/skins/django/",
         updateSelector: 'input[type=submit],',
         updateEvent: 'click',
 		logoHtml: '',

File cmsplugin_news/widgets/

-from os.path import join
 from django.utils.safestring import mark_safe
 from django.template.loader import render_to_string
 from django.forms import Textarea
 from django.conf import settings
+from cms.utils import cms_static_url
 from cms.plugins.text import settings as text_settings
 from django.utils.translation.trans_real import get_language
 class WYMEditor(Textarea):
     class Media:
-        js = [join(settings.CMS_MEDIA_URL, path) for path in (
-            'js/lib/jquery.js',
+        js = [cms_static_url(path) for path in (
+            'js/plugins/admincompat.js',
     def __init__(self, attrs=None, installed_plugins=None):
         Create a widget for editing text + plugins.
         super(WYMEditor, self).__init__(attrs)
         self.installed_plugins = installed_plugins
     def render_textarea(self, name, value, attrs=None):
         return super(WYMEditor, self).render(name, value, attrs)
         context = {
             'name': name,
             'language': language,
-            'CMS_MEDIA_URL': settings.CMS_MEDIA_URL,
+            'STATIC_URL': settings.STATIC_URL,
             'WYM_TOOLS': mark_safe(text_settings.WYM_TOOLS),
             'WYM_CONTAINERS': mark_safe(text_settings.WYM_CONTAINERS),
             'WYM_CLASSES': mark_safe(text_settings.WYM_CLASSES),
     def render(self, name, value, attrs=None):
         return self.render_textarea(name, value, attrs) + \
-            self.render_additions(name, value, attrs)
+            self.render_additions(name, value, attrs)