From 26031cd1f497d31f0aaf0e87fbad02c45e520b5e Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 8 Feb 2010 15:02:17 +0000 Subject: [PATCH] notification enabled field added to discussion control panel. svn path=/plone.app.discussion/branches/notification/; revision=33869 --- plone/app/discussion/browser/comments.py | 6 +++++- plone/app/discussion/browser/controlpanel.py | 2 ++ plone/app/discussion/interfaces.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 2887a91..6c7cd44 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -62,12 +62,16 @@ class CommentForm(extensible.ExtensibleForm, form.Form): def updateWidgets(self): super(CommentForm, self).updateWidgets() self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE - portal_membership = getToolByName(self.context, 'portal_membership') self.widgets['text'].addClass("autoresize") self.widgets['author_notification'].label = _(u"") + portal_membership = getToolByName(self.context, 'portal_membership') if not portal_membership.isAnonymousUser(): self.widgets['author_name'].mode = interfaces.HIDDEN_MODE self.widgets['author_email'].mode = interfaces.HIDDEN_MODE + registry = queryUtility(IRegistry) + settings = registry.forInterface(IDiscussionSettings) + if not settings.notification_enabled: + self.widgets['author_notification'].mode = interfaces.HIDDEN_MODE def updateActions(self): super(CommentForm, self).updateActions() diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py index b7d0c91..8bd3892 100644 --- a/plone/app/discussion/browser/controlpanel.py +++ b/plone/app/discussion/browser/controlpanel.py @@ -29,12 +29,14 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm): self.fields['globally_enabled'].widgetFactory = SingleCheckBoxFieldWidget self.fields['anonymous_comments'].widgetFactory = SingleCheckBoxFieldWidget self.fields['show_commenter_image'].widgetFactory = SingleCheckBoxFieldWidget + self.fields['notification_enabled'].widgetFactory = SingleCheckBoxFieldWidget def updateWidgets(self): super(DiscussionSettingsEditForm, self).updateWidgets() self.widgets['globally_enabled'].label = _(u"Enable Comments") self.widgets['anonymous_comments'].label = _(u"Anonymous Comments") self.widgets['show_commenter_image'].label = _(u"Commenter Image") + self.widgets['notification_enabled'].label = _(u"Email Notification") class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py index 2cfb86b..8e0ca54 100644 --- a/plone/app/discussion/interfaces.py +++ b/plone/app/discussion/interfaces.py @@ -55,6 +55,17 @@ class IDiscussionSettings(Interface): required=False, default=True) + notification_enabled = schema.Bool( + title=_(u"label_notification_enabled", + default=u"Enable email notification"), + description=_(u"help_notification_enabled", + default=u"If selected, users can " + "choose to be notified " + "of new comments by " + "email."), + required=False, + default=False) + class IConversation(IIterableMapping): """A conversation about a content object.