Luke Plant avatar Luke Plant committed 2c49336

Fixed issue 26 (class list not available on new Text/layout)

Comments (0)

Files changed (1)

semanticeditor/cms_plugins.py

+from cms.models import Page
 from cms.plugins.text.cms_plugins import TextPlugin
 from cms.plugins.text.models import Text
 from cms.plugins.text.forms import TextForm
+from cms.plugins.text.utils import plugin_tags_to_user_html
 from cms.plugin_pool import plugin_pool
 from cms.plugin_base import CMSPluginBase
 from django.utils.translation import ugettext_lazy as _
 
 from semanticeditor.widgets import SemanticEditor
-from cms.plugins.text.utils import plugin_tags_to_user_html
 from django.forms.fields import CharField
 
+import re
+
 class SemanticTextPlugin(TextPlugin):
 
     name = _("Text/layout")
         page = None
         if obj:
             page = obj.page
+        else:
+            # Ugly hack here - we really need to get the page id.
+            m = re.search("/page/(\d+)/edit-plugin/(\d+)/$", request.path)
+            if m is not None:
+                page = Page.objects.get(pk=int(m.groups()[0]))
+
+        if page is None:
+            import warnings
+            warnings.warn("Could not work out what page we are on, which will result in problems with class list")
+
         plugins = plugin_pool.get_text_enabled_plugins(self.placeholder)
         form = self.get_form_class(request, plugins, page)
         kwargs['form'] = form # override standard form
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.