Added basic infrastructure for discussion controlpanel.
svn path=/plone.app.discussion/trunk/; revision=27269
This commit is contained in:
parent
47911fa24a
commit
f27156e916
@ -3,6 +3,8 @@
|
|||||||
xmlns:browser="http://namespaces.zope.org/browser"
|
xmlns:browser="http://namespaces.zope.org/browser"
|
||||||
i18n_domain="plone.app.discussion">
|
i18n_domain="plone.app.discussion">
|
||||||
|
|
||||||
|
<include package="plone.app.registry" />
|
||||||
|
|
||||||
<!-- Traversal adapter -->
|
<!-- Traversal adapter -->
|
||||||
<adapter factory=".traversal.ConversationNamespace" name="conversation" />
|
<adapter factory=".traversal.ConversationNamespace" name="conversation" />
|
||||||
|
|
||||||
@ -66,4 +68,20 @@
|
|||||||
layer="..interfaces.IDiscussionLayer"
|
layer="..interfaces.IDiscussionLayer"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<browser:page
|
||||||
|
name="discussion-settings"
|
||||||
|
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
||||||
|
class=".controlpanel.DiscussionSettingsControlPanel"
|
||||||
|
permission="cmf.ManagePortal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Utility view - use in portal_css or similar as portal/@@xdv-check/enabled" -->
|
||||||
|
<browser:page
|
||||||
|
name="discussion-check"
|
||||||
|
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
||||||
|
class=".controlpanel.Utility"
|
||||||
|
permission="zope.Public"
|
||||||
|
allowed_attributes="globally_enabled"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
from Products.Five.browser import BrowserView
|
||||||
|
|
||||||
|
from zope.component import queryUtility
|
||||||
|
from plone.registry.interfaces import IRegistry
|
||||||
|
|
||||||
|
from plone.app.registry.browser import controlpanel
|
||||||
|
|
||||||
|
from plone.app.discussion.interfaces import IDiscussionSettings, _
|
||||||
|
|
||||||
|
try:
|
||||||
|
# only in z3c.form 2.0
|
||||||
|
from z3c.form.browser.textlines import TextLinesFieldWidget
|
||||||
|
from z3c.form.browser.widget import SingleCheckBoxWidget
|
||||||
|
except ImportError:
|
||||||
|
from plone.z3cform.textlines import TextLinesFieldWidget
|
||||||
|
from plone.z3cform.widget import SingleCheckBoxWidget
|
||||||
|
|
||||||
|
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
||||||
|
|
||||||
|
schema = IDiscussionSettings
|
||||||
|
label = _(u"Discussion settings")
|
||||||
|
description = _(u"Please enter the options specified")
|
||||||
|
|
||||||
|
def updateFields(self):
|
||||||
|
super(DiscussionSettingsEditForm, self).updateFields()
|
||||||
|
#self.fields['globally_enabled'].widgetFactory = SingleCheckBoxWidget
|
||||||
|
|
||||||
|
def updateWidgets(self):
|
||||||
|
super(DiscussionSettingsEditForm, self).updateWidgets()
|
||||||
|
|
||||||
|
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
|
||||||
|
form = DiscussionSettingsEditForm
|
||||||
|
|
||||||
|
class Utility(BrowserView):
|
||||||
|
"""Utility view to determine if the site is currently styled with xdv
|
||||||
|
"""
|
||||||
|
|
||||||
|
def globally_enabled(self):
|
||||||
|
"""Determine if the utility is enabled and we are in an enabled domain
|
||||||
|
"""
|
||||||
|
|
||||||
|
registry = queryUtility(IRegistry)
|
||||||
|
if registry is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
settings = None
|
||||||
|
try:
|
||||||
|
settings = registry.for_interface(IDiscussionSettings)
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not settings.globally_enabled:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
@ -11,9 +11,9 @@ class IDiscussionSettings(Interface):
|
|||||||
configuration registry and obtainable via plone.registry.
|
configuration registry and obtainable via plone.registry.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
globally_enabled = schema.Bool(title=_(u"Globally enabled"),
|
#globally_enabled = schema.Bool(title=_(u"Globally enabled"),
|
||||||
description=_(u"Use this setting to enable or disable comments globally"),
|
# description=_(u"Use this setting to enable or disable comments globally"),
|
||||||
default=True)
|
# default=True)
|
||||||
|
|
||||||
class IConversation(IIterableMapping):
|
class IConversation(IIterableMapping):
|
||||||
"""A conversation about a content object.
|
"""A conversation about a content object.
|
||||||
|
20
plone/app/discussion/profiles/default/controlpanel.xml
Normal file
20
plone/app/discussion/profiles/default/controlpanel.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<object
|
||||||
|
name="portal_controlpanel"
|
||||||
|
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
||||||
|
i18n:domain="plone.app.discussion"
|
||||||
|
purge="False">
|
||||||
|
|
||||||
|
<configlet
|
||||||
|
title="Discussion"
|
||||||
|
action_id="discussion"
|
||||||
|
appId="plone.app.discussion"
|
||||||
|
category="Products"
|
||||||
|
condition_expr=""
|
||||||
|
url_expr="string:${portal_url}/@@discussion-settings"
|
||||||
|
visible="True"
|
||||||
|
i18n:attributes="title">
|
||||||
|
<permission>Manage portal</permission>
|
||||||
|
</configlet>
|
||||||
|
|
||||||
|
</object>
|
4
plone/app/discussion/profiles/default/registry.xml
Normal file
4
plone/app/discussion/profiles/default/registry.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<registry>
|
||||||
|
<records interface="plone.app.discussion.interfaces.IDiscussionSettings" />
|
||||||
|
</registry>
|
4
setup.py
4
setup.py
@ -27,14 +27,16 @@ setup(name='plone.app.discussion',
|
|||||||
'setuptools',
|
'setuptools',
|
||||||
'collective.autopermission',
|
'collective.autopermission',
|
||||||
'collective.testcaselayer',
|
'collective.testcaselayer',
|
||||||
|
'plone.app.registry',
|
||||||
'plone.indexer',
|
'plone.indexer',
|
||||||
|
'plone.registry',
|
||||||
|
'plone.z3cform',
|
||||||
'ZODB3',
|
'ZODB3',
|
||||||
'zope.interface',
|
'zope.interface',
|
||||||
'zope.component',
|
'zope.component',
|
||||||
'zope.annotation',
|
'zope.annotation',
|
||||||
'zope.event',
|
'zope.event',
|
||||||
'zope.app.container', # XXX: eventually should change to zope.container
|
'zope.app.container', # XXX: eventually should change to zope.container
|
||||||
'plone.indexer',
|
|
||||||
],
|
],
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[z3c.autoinclude.plugin]
|
[z3c.autoinclude.plugin]
|
||||||
|
Loading…
Reference in New Issue
Block a user