Skip to content

Commit

Permalink
Added navigation_local option - for setting local panel managers
Browse files Browse the repository at this point in the history
  on INavigationRoot instead of ISiteRoot. Useful eg. with modules for
  multilingual content.
  • Loading branch information
tmog committed Mar 20, 2013
1 parent 8804c7c commit 537ed3b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ In next release ...

Features:

- Added navigation_local option - for setting local panel managers
on INavigationRoot instead of ISiteRoot. Useful eg. with modules for
multilingual content.
[tmog]

- Added function to duplicate an existing panel.

- The "Manage panels" form now has a better default styling.
Expand Down
19 changes: 16 additions & 3 deletions src/collective/panels/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.statusmessages.interfaces import IStatusMessage
from Products.CMFCore.interfaces import ISiteRoot
from plone.app.layout.navigation.interfaces import INavigationRoot
from ZODB.POSException import ConflictError
from zExceptions import NotFound

Expand Down Expand Up @@ -262,6 +263,18 @@ def __call__(self):

class BaseViewlet(ViewletBase):

def __init__(self, context, request, view, manager=None):
super(BaseViewlet, self).__init__(context, request, view, manager)

self.root_interface = ISiteRoot
try:
settings = getUtility(IRegistry).forInterface(IGlobalSettings)
except (ComponentLookupError, KeyError):
pass
else:
if settings.navigation_local:
self.root_interface = INavigationRoot

@property
def can_manage(self):
try:
Expand All @@ -274,7 +287,7 @@ def can_manage(self):
else:
for interface in settings.site_local_managers or ():
if interface.providedBy(self.manager):
if not ISiteRoot.providedBy(self.context):
if not self.root_interface.providedBy(self.context):
return False

if IManagePanels.providedBy(self.request):
Expand Down Expand Up @@ -382,7 +395,7 @@ def _iter_enabled_viewlet_managers(self):
except (ComponentLookupError, KeyError):
ignore_list = ()
else:
if not ISiteRoot.providedBy(self.context):
if not self.root_interface.providedBy(self.context):
ignore_list = settings.site_local_managers or ()
else:
ignore_list = ()
Expand Down Expand Up @@ -426,7 +439,7 @@ def panels(self):
else:
for interface in settings.site_local_managers or ():
if interface.providedBy(self.manager):
while not ISiteRoot.providedBy(context):
while not self.root_interface.providedBy(context):
context = context.aq_parent
if context is None:
raise RuntimeError("No site found.")
Expand Down
10 changes: 10 additions & 0 deletions src/collective/panels/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ class IGlobalSettings(Interface):
)
)

navigation_local = schema.Bool(
title=_(u"Use navigation root"),
description=_(u"Site-local panel managers will be assignable "
u"on navigation roots instead of only site roots "
u"if you select this option. Check this if you are "
u"using LinguaPlone, collective.multilingual or "
u"similar, and you want per-language Site-local "
u"panel managers."),
)

spacing = schema.Float(
title=_(u"Column spacing"),
description=_(u"This is the horizontal distance between "
Expand Down
6 changes: 6 additions & 0 deletions src/collective/panels/locales/collective.panels.pot
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@ msgid "Manage panel"
msgstr ""

msgid "Spacing changed"
msgstr ""

msgid "Use navigation root"
msgstr ""

msgid "Site-local panel managers will be assignable on navigation roots instead of only site roots if you select this option. Check this if you are using LinguaPlone, collective.multilingual or similar, and you want per-language Site-local panel managers.Spacing changed"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,9 @@ msgid "Select this option to omit margins on the left- and right side of a panel
msgstr "Vælg denne mulighed for at udelade venstre- og højre-margen omkring et panel."
msgid "Manage panels"
msgstr "Administrer paneler"

msgid "Use navigation root"
msgstr "Benyt navigationrod i stedet for siterod"

msgid "Site-local panel managers will be assignable on navigation roots instead of only site roots if you select this option. Check this if you are using LinguaPlone, collective.multilingual or similar, and you want per-language Site-local panel managers."
msgstr "Vælg dette hvis sitet bruger LinguaPlone, collective.multilingual el.lign. modul til indholdsoversættelse. Placeringer med oprettelse på site-basis vil derefter kunne konfigureres per sprog."

0 comments on commit 537ed3b

Please sign in to comment.