Skip to content

Commit

Permalink
attempt at fixing django-cms#800
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Jun 13, 2011
1 parent c5e8258 commit ec1ee5c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
9 changes: 1 addition & 8 deletions cms/forms/widgets.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
from os.path import join from os.path import join
import copy 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): class PageSelectWidget(MultiWidget):
"""A widget that allows selecting a page by first selecting a site and then """A widget that allows selecting a page by first selecting a site and then
a page on that site in a two step process. a page on that site in a two step process.
Expand Down Expand Up @@ -210,11 +205,9 @@ def render(self, name, value, attrs=None):
model=ph._get_attached_model(), model=ph._get_attached_model(),
fieldname=ph._get_attached_field_name() 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 = { context = {
'plugin_list': plugin_list, 'plugin_list': plugin_list,
'installed_plugins': installed_plugins, 'installed_plugins': plugin_pool.get_all_plugins(ph.slot, page_only=False),
'copy_languages': copy_languages, 'copy_languages': copy_languages,
'language': language, 'language': language,
'show_copy': bool(copy_languages) and ph.actions.can_copy, 'show_copy': bool(copy_languages) and ph.actions.can_copy,
Expand Down
1 change: 1 addition & 0 deletions cms/plugin_base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class CMSPluginBase(admin.ModelAdmin):
render_plugin = True render_plugin = True
model = CMSPlugin model = CMSPlugin
text_enabled = False text_enabled = False
page_only = False


opts = {} opts = {}
module = None #track in which module/application belongs module = None #track in which module/application belongs
Expand Down
5 changes: 3 additions & 2 deletions cms/plugin_pool.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def unregister_plugin(self, plugin):
) )
del self.plugins[plugin_name] 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() self.discover_plugins()
plugins = self.plugins.values()[:] plugins = self.plugins.values()[:]
plugins.sort(key=lambda obj: unicode(obj.name)) plugins.sort(key=lambda obj: unicode(obj.name))
Expand All @@ -80,7 +80,8 @@ def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins"):
getattr(page, 'template', None) getattr(page, 'template', None)
) )
if allowed_plugins: 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) final_plugins.append(plugin)
elif setting_key == "plugins": elif setting_key == "plugins":
final_plugins.append(plugin) final_plugins.append(plugin)
Expand Down
1 change: 1 addition & 0 deletions cms/plugins/inherit/cms_plugins.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class InheritPagePlaceholderPlugin(CMSPluginBase):
render_template = "cms/plugins/inherit_plugins.html" render_template = "cms/plugins/inherit_plugins.html"
form = InheritForm form = InheritForm
admin_preview = False admin_preview = False
page_only = True


def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
template_vars = { template_vars = {
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/placeholder.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_fieldsets(self):
phfields.remove(field) phfields.remove(field)
self.assertEqual(phfields, []) self.assertEqual(phfields, [])


def test_no_inheritplugin_nopage(self): def test_page_only_plugins(self):
ex = Example1( ex = Example1(
char_1='one', char_1='one',
char_2='two', char_2='two',
Expand Down

0 comments on commit ec1ee5c

Please sign in to comment.