notification enabled field added to discussion control panel.

svn path=/plone.app.discussion/branches/notification/; revision=33869
This commit is contained in:
Timo Stollenwerk 2010-02-08 15:02:17 +00:00
parent de3bb53c13
commit 26031cd1f4
3 changed files with 18 additions and 1 deletions

View File

@ -62,12 +62,16 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
def updateWidgets(self): def updateWidgets(self):
super(CommentForm, self).updateWidgets() super(CommentForm, self).updateWidgets()
self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE
portal_membership = getToolByName(self.context, 'portal_membership')
self.widgets['text'].addClass("autoresize") self.widgets['text'].addClass("autoresize")
self.widgets['author_notification'].label = _(u"") self.widgets['author_notification'].label = _(u"")
portal_membership = getToolByName(self.context, 'portal_membership')
if not portal_membership.isAnonymousUser(): if not portal_membership.isAnonymousUser():
self.widgets['author_name'].mode = interfaces.HIDDEN_MODE self.widgets['author_name'].mode = interfaces.HIDDEN_MODE
self.widgets['author_email'].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): def updateActions(self):
super(CommentForm, self).updateActions() super(CommentForm, self).updateActions()

View File

@ -29,12 +29,14 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
self.fields['globally_enabled'].widgetFactory = SingleCheckBoxFieldWidget self.fields['globally_enabled'].widgetFactory = SingleCheckBoxFieldWidget
self.fields['anonymous_comments'].widgetFactory = SingleCheckBoxFieldWidget self.fields['anonymous_comments'].widgetFactory = SingleCheckBoxFieldWidget
self.fields['show_commenter_image'].widgetFactory = SingleCheckBoxFieldWidget self.fields['show_commenter_image'].widgetFactory = SingleCheckBoxFieldWidget
self.fields['notification_enabled'].widgetFactory = SingleCheckBoxFieldWidget
def updateWidgets(self): def updateWidgets(self):
super(DiscussionSettingsEditForm, self).updateWidgets() super(DiscussionSettingsEditForm, self).updateWidgets()
self.widgets['globally_enabled'].label = _(u"Enable Comments") self.widgets['globally_enabled'].label = _(u"Enable Comments")
self.widgets['anonymous_comments'].label = _(u"Anonymous Comments") self.widgets['anonymous_comments'].label = _(u"Anonymous Comments")
self.widgets['show_commenter_image'].label = _(u"Commenter Image") self.widgets['show_commenter_image'].label = _(u"Commenter Image")
self.widgets['notification_enabled'].label = _(u"Email Notification")
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):

View File

@ -55,6 +55,17 @@ class IDiscussionSettings(Interface):
required=False, required=False,
default=True) 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): class IConversation(IIterableMapping):
"""A conversation about a content object. """A conversation about a content object.