fix singlecheckboxwidget for comment form.
svn path=/plone.app.discussion/branches/notification/; revision=33873
This commit is contained in:
parent
26031cd1f4
commit
67b5ff566e
@ -57,21 +57,29 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
'author_username')
|
'author_username')
|
||||||
|
|
||||||
def updateFields(self):
|
def updateFields(self):
|
||||||
|
super(CommentForm, self).updateFields()
|
||||||
self.fields['author_notification'].widgetFactory = SingleCheckBoxFieldWidget
|
self.fields['author_notification'].widgetFactory = SingleCheckBoxFieldWidget
|
||||||
|
|
||||||
def updateWidgets(self):
|
def updateWidgets(self):
|
||||||
super(CommentForm, self).updateWidgets()
|
super(CommentForm, self).updateWidgets()
|
||||||
|
|
||||||
|
# Widgets
|
||||||
self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE
|
self.widgets['in_reply_to'].mode = interfaces.HIDDEN_MODE
|
||||||
self.widgets['text'].addClass("autoresize")
|
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')
|
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)
|
# Notification enabled
|
||||||
if not settings.notification_enabled:
|
# XXX: Not working! ComponentLookupError
|
||||||
self.widgets['author_notification'].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()
|
||||||
@ -90,6 +98,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
author_name = u""
|
author_name = u""
|
||||||
author_username = u""
|
author_username = u""
|
||||||
author_email = u""
|
author_email = u""
|
||||||
|
author_notification = None
|
||||||
|
|
||||||
# Captcha check for anonymous users (if Captcha is enabled)
|
# Captcha check for anonymous users (if Captcha is enabled)
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
|
@ -168,7 +168,8 @@ class IComment(Interface):
|
|||||||
Comments are indexed in the catalog and subject to workflow and security.
|
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)
|
__parent__ = schema.Object(title=_(u"Conversation"), schema=Interface)
|
||||||
__name__ = schema.TextLine(title=_(u"Name"))
|
__name__ = schema.TextLine(title=_(u"Name"))
|
||||||
@ -188,7 +189,9 @@ class IComment(Interface):
|
|||||||
mime_type = schema.ASCIILine(title=_(u"MIME type"), default="text/plain")
|
mime_type = schema.ASCIILine(title=_(u"MIME type"), default="text/plain")
|
||||||
text = schema.Text(title=_(u"Comment"))
|
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)"))
|
creator = schema.TextLine(title=_(u"Author name (for display)"))
|
||||||
creation_date = schema.Date(title=_(u"Creation date"))
|
creation_date = schema.Date(title=_(u"Creation date"))
|
||||||
|
@ -61,5 +61,12 @@ class RegistryTest(PloneTestCase):
|
|||||||
self.failUnless('show_commenter_image' in IDiscussionSettings)
|
self.failUnless('show_commenter_image' in IDiscussionSettings)
|
||||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'], True)
|
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():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
Loading…
Reference in New Issue
Block a user