Permalink
Browse files

attempt at fixing #800

  • Loading branch information...
1 parent c5e8258 commit ec1ee5c52d40591879e9daa155d62ce4e9e10e19 @fivethreeo fivethreeo committed Jun 13, 2011
Showing with 7 additions and 11 deletions.
  1. +1 −8 cms/forms/widgets.py
  2. +1 −0 cms/plugin_base.py
  3. +3 −2 cms/plugin_pool.py
  4. +1 −0 cms/plugins/inherit/cms_plugins.py
  5. +1 −1 cms/tests/placeholder.py
View
9 cms/forms/widgets.py
@@ -14,11 +14,6 @@
from os.path import join
import copy
-PAGE_ONLY_PLUGINS = []
-if 'cms.plugins.inherit' in settings.INSTALLED_APPS:
- from cms.plugins.inherit.cms_plugins import InheritPagePlaceholderPlugin
- PAGE_ONLY_PLUGINS.append(InheritPagePlaceholderPlugin)
-
class PageSelectWidget(MultiWidget):
"""A widget that allows selecting a page by first selecting a site and then
a page on that site in a two step process.
@@ -210,11 +205,9 @@ def render(self, name, value, attrs=None):
model=ph._get_attached_model(),
fieldname=ph._get_attached_field_name()
)
- installed_plugins = [plugin for plugin in plugin_pool.get_all_plugins(ph.slot) \
- if plugin not in PAGE_ONLY_PLUGINS]
context = {
'plugin_list': plugin_list,
- 'installed_plugins': installed_plugins,
+ 'installed_plugins': plugin_pool.get_all_plugins(ph.slot, page_only=False),
'copy_languages': copy_languages,
'language': language,
'show_copy': bool(copy_languages) and ph.actions.can_copy,
View
1 cms/plugin_base.py
@@ -90,6 +90,7 @@ class CMSPluginBase(admin.ModelAdmin):
render_plugin = True
model = CMSPlugin
text_enabled = False
+ page_only = False
opts = {}
module = None #track in which module/application belongs
View
5 cms/plugin_pool.py
@@ -67,7 +67,7 @@ def unregister_plugin(self, plugin):
)
del self.plugins[plugin_name]
- def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins"):
+ def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins", page_only=True):
self.discover_plugins()
plugins = self.plugins.values()[:]
plugins.sort(key=lambda obj: unicode(obj.name))
@@ -80,7 +80,8 @@ def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins"):
getattr(page, 'template', None)
)
if allowed_plugins:
- if plugin.__name__ in allowed_plugins:
+ if plugin.__name__ in allowed_plugins and \
+ (plugin.page_only is True and page_only is False):
final_plugins.append(plugin)
elif setting_key == "plugins":
final_plugins.append(plugin)
View
1 cms/plugins/inherit/cms_plugins.py
@@ -18,6 +18,7 @@ class InheritPagePlaceholderPlugin(CMSPluginBase):
render_template = "cms/plugins/inherit_plugins.html"
form = InheritForm
admin_preview = False
+ page_only = True
def render(self, context, instance, placeholder):
template_vars = {
View
2 cms/tests/placeholder.py
@@ -108,7 +108,7 @@ def test_fieldsets(self):
phfields.remove(field)
self.assertEqual(phfields, [])
- def test_no_inheritplugin_nopage(self):
+ def test_page_only_plugins(self):
ex = Example1(
char_1='one',
char_2='two',

0 comments on commit ec1ee5c

Please sign in to comment.