add anonymous_email_enabled settings to really let integrator activate it. add the migration script which add the option to the registry and do not change the behavior: the email will not be displayed by default

This commit is contained in:
JeanMichel FRANCOIS 2013-01-04 19:00:24 +01:00
parent 84ba3661e0
commit a16958c1c7
5 changed files with 29 additions and 6 deletions

View File

@ -105,13 +105,12 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
self.widgets['author_name'].mode = interfaces.HIDDEN_MODE
self.widgets['author_email'].mode = interfaces.HIDDEN_MODE
# Todo: Since we are not using the author_email field in the
# current state, we hide it by default. But we keep the field for
# integrators or later use.
self.widgets['author_email'].mode = interfaces.HIDDEN_MODE
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
if mtool.isAnonymousUser() and not settings.anonymous_email_enabled:
self.widgets['author_email'].mode = interfaces.HIDDEN_MODE
member = mtool.getAuthenticatedMember()
member_email = member.getProperty('email')

View File

@ -322,6 +322,15 @@ class IDiscussionSettings(Interface):
required=False,
default=False)
anonymous_email_enabled = schema.Bool(
title=_(u"label_anonymous_email_enabled",
default=u"Enable anonymous email field"),
description=_(u"help_anonymous_email_enabled",
default=u"If selected, anonymous user will have to "
"give their email."),
required=False,
default=False)
class IDiscussionLayer(Interface):
"""Request marker installed via browserlayer.xml.

View File

@ -1,5 +1,5 @@
<metadata>
<version>100</version>
<version>110</version>
<dependencies>
<dependency>profile-plone.app.registry:default</dependency>
</dependencies>

View File

@ -6,3 +6,10 @@ from plone.app.discussion.interfaces import IDiscussionSettings
def update_registry(context):
registry = getUtility(IRegistry)
registry.registerInterface(IDiscussionSettings)
def add_anonymous_email_enabled_settings(context):
registry = getUtility(IRegistry)
key = 'plone.app.discussion.interfaces.IDiscussionSettings.'
key += 'anonymous_email_enabled'
registry[key] = False

View File

@ -11,4 +11,12 @@
handler=".upgrades.update_registry"
/>
<genericsetup:upgradeStep
source="*"
destination="110"
title="Update plone.app.discussion setting registry"
description=""
profile="plone.app.discussion:default"
handler=".upgrades.update_registry"
/>
</configure>