Skip to content

Commit

Permalink
test and fix for #800
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Jun 10, 2011
1 parent 8cf41fe commit d666a7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cms/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
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.
Expand Down Expand Up @@ -205,9 +210,11 @@ 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': plugin_pool.get_all_plugins(ph.slot),
'installed_plugins': installed_plugins,
'copy_languages': copy_languages,
'language': language,
'show_copy': bool(copy_languages) and ph.actions.can_copy,
Expand Down
14 changes: 13 additions & 1 deletion cms/tests/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,19 @@ def test_fieldsets(self):
self.assertTrue('plugin-holder-nopage' in fieldset['classes'])
phfields.remove(field)
self.assertEqual(phfields, [])


def test_no_inheritplugin_nopage(self):
ex = Example1(
char_1='one',
char_2='two',
char_3='tree',
char_4='four'
)
ex.save()
response = self.client.get(reverse('admin:placeholderapp_example1_change', args=(ex.pk,)))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, 'InheritPagePlaceholderPlugin')

def test_placeholder_scanning_fail(self):
self.assertRaises(TemplateSyntaxError, get_placeholders, 'placeholder_tests/test_eleven.html')

Expand Down

0 comments on commit d666a7d

Please sign in to comment.