diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 6c7cd44..f01b28e 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -57,21 +57,29 @@ class CommentForm(extensible.ExtensibleForm, form.Form): 'author_username') def updateFields(self): + super(CommentForm, self).updateFields() self.fields['author_notification'].widgetFactory = SingleCheckBoxFieldWidget - + def updateWidgets(self): super(CommentForm, self).updateWidgets() + + # Widgets self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE self.widgets['text'].addClass("autoresize") - self.widgets['author_notification'].label = _(u"") + self.widgets['author_notification'].label = _(u"") + + # Anonymous / Logged-in 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 + + # Notification enabled + # XXX: Not working! ComponentLookupError + #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() @@ -90,6 +98,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form): author_name = u"" author_username = u"" author_email = u"" + author_notification = None # Captcha check for anonymous users (if Captcha is enabled) registry = queryUtility(IRegistry) diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py index 8e0ca54..38b284a 100644 --- a/plone/app/discussion/interfaces.py +++ b/plone/app/discussion/interfaces.py @@ -168,7 +168,8 @@ class IComment(Interface): Comments are indexed in the catalog and subject to workflow and security. """ - portal_type = schema.ASCIILine(title=_(u"Portal type"), default="Discussion Item") + portal_type = schema.ASCIILine(title=_(u"Portal type"), + default="Discussion Item") __parent__ = schema.Object(title=_(u"Conversation"), schema=Interface) __name__ = schema.TextLine(title=_(u"Name")) @@ -188,7 +189,9 @@ class IComment(Interface): mime_type = schema.ASCIILine(title=_(u"MIME type"), default="text/plain") text = schema.Text(title=_(u"Comment")) - author_notification = schema.Bool(title=_("Notify me of new posts via email"), required=False) + author_notification = schema.Bool(title=_(u"Notify me of new comments via " + "email."), + required=False) creator = schema.TextLine(title=_(u"Author name (for display)")) creation_date = schema.Date(title=_(u"Creation date")) diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 98c5369..b255e24 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -86,7 +86,7 @@ class TestCommentsViewletIntegration(FunctionalTestCase): browser.getLink(id='document').click() browser.getControl(name='title').value = "Doc1" browser.getControl(name='allowDiscussion:boolean').value = True - browser.getControl(name='form.button.save').click() + browser.getControl(name='form.button.save').click() doc1 = self.portal['doc1'] doc1_url = doc1.absolute_url() diff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py index 160c130..cc13f93 100644 --- a/plone/app/discussion/tests/test_controlpanel.py +++ b/plone/app/discussion/tests/test_controlpanel.py @@ -61,5 +61,12 @@ class RegistryTest(PloneTestCase): self.failUnless('show_commenter_image' in IDiscussionSettings) self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'], True) + def test_notification_enabled(self): + # Check show_commenter_image record + show_commenter_image = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.notification_enabled'] + + self.failUnless('notification_enabled' in IDiscussionSettings) + self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.notification_enabled'], False) + def test_suite(): return unittest.defaultTestLoader.loadTestsFromName(__name__) \ No newline at end of file