From a16958c1c7dbcc24808e51518b0d2ac53043801c Mon Sep 17 00:00:00 2001 From: JeanMichel FRANCOIS Date: Fri, 4 Jan 2013 19:00:24 +0100 Subject: [PATCH] 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 --- plone/app/discussion/browser/comments.py | 9 ++++----- plone/app/discussion/interfaces.py | 9 +++++++++ plone/app/discussion/profiles/default/metadata.xml | 2 +- plone/app/discussion/upgrades.py | 7 +++++++ plone/app/discussion/upgrades.zcml | 8 ++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index ffd2e32..7bbd391 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -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') diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py index 2965289..d305bcb 100644 --- a/plone/app/discussion/interfaces.py +++ b/plone/app/discussion/interfaces.py @@ -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. diff --git a/plone/app/discussion/profiles/default/metadata.xml b/plone/app/discussion/profiles/default/metadata.xml index ffedb11..82d4326 100644 --- a/plone/app/discussion/profiles/default/metadata.xml +++ b/plone/app/discussion/profiles/default/metadata.xml @@ -1,5 +1,5 @@ - 100 + 110 profile-plone.app.registry:default diff --git a/plone/app/discussion/upgrades.py b/plone/app/discussion/upgrades.py index bf9df71..618fd4e 100644 --- a/plone/app/discussion/upgrades.py +++ b/plone/app/discussion/upgrades.py @@ -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 diff --git a/plone/app/discussion/upgrades.zcml b/plone/app/discussion/upgrades.zcml index b1854d0..92495c5 100644 --- a/plone/app/discussion/upgrades.zcml +++ b/plone/app/discussion/upgrades.zcml @@ -11,4 +11,12 @@ handler=".upgrades.update_registry" /> +