This commit is contained in:
tisto 2012-01-14 07:13:39 +01:00
parent f520482eb3
commit a3883d7e7b
7 changed files with 25 additions and 22 deletions

View File

@ -42,7 +42,8 @@ class CaptchaExtender(extensible.FormExtender):
registered when a plugin is installed that provides the registered when a plugin is installed that provides the
"plone.app.discussion-captcha" feature. "plone.app.discussion-captcha" feature.
""" """
adapts(Interface, IDefaultBrowserLayer, CommentForm) # context, request, form # context, request, form
adapts(Interface, IDefaultBrowserLayer, CommentForm)
fields = Fields(ICaptcha) fields = Fields(ICaptcha)
@ -66,10 +67,10 @@ class CaptchaExtender(extensible.FormExtender):
self.form.fields['captcha'].widgetFactory = CaptchaFieldWidget self.form.fields['captcha'].widgetFactory = CaptchaFieldWidget
elif self.captcha == 'recaptcha': elif self.captcha == 'recaptcha':
from plone.formwidget.recaptcha import ReCaptchaFieldWidget from plone.formwidget.recaptcha import ReCaptchaFieldWidget
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget self.form.fields['captcha'].widgetFactory = \
ReCaptchaFieldWidget
elif self.captcha == 'norobots': elif self.captcha == 'norobots':
from collective.z3cform.norobots import NorobotsFieldWidget from collective.z3cform.norobots import NorobotsFieldWidget
self.form.fields['captcha'].widgetFactory = NorobotsFieldWidget self.form.fields['captcha'].widgetFactory = NorobotsFieldWidget
else: else:
self.form.fields['captcha'].mode = interfaces.HIDDEN_MODE self.form.fields['captcha'].mode = interfaces.HIDDEN_MODE

View File

@ -73,7 +73,7 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
if errors: if errors:
self.status = self.formErrorsMessage self.status = self.formErrorsMessage
return return
changes = self.applyChanges(data) self.applyChanges(data)
IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
"info") "info")
self.context.REQUEST.RESPONSE.redirect("@@discussion-settings") self.context.REQUEST.RESPONSE.redirect("@@discussion-settings")

View File

@ -126,7 +126,7 @@ class Conversation(Traversable, Persistent, Explicit):
children = self._children.get(comment_id, None) children = self._children.get(comment_id, None)
if children is not None: if children is not None:
for child_id in children: for child_id in children:
for value in recurse(child_id, d+1): for value in recurse(child_id, d + 1):
yield value yield value
# Find top level threads # Find top level threads
@ -295,9 +295,9 @@ try:
except ImportError: except ImportError:
pass pass
else: else:
@implementer(IConversation) # pragma: no cover @implementer(IConversation) # pragma: no cover
@adapter(IAnnotatable) # pragma: no cover @adapter(IAnnotatable) # pragma: no cover
def conversationCanonicalAdapterFactory(content): # pragma: no cover def conversationCanonicalAdapterFactory(content): # pragma: no cover
"""Adapter factory to fetch the default conversation from annotations. """Adapter factory to fetch the default conversation from annotations.
Will create the conversation if it does not exist. Will create the conversation if it does not exist.
@ -318,7 +318,7 @@ class ConversationReplies(object):
""" """
implements(IReplies) implements(IReplies)
adapts(Conversation) # relies on implementation details adapts(Conversation) # relies on implementation details
def __init__(self, context): def __init__(self, context):
self.conversation = context self.conversation = context
@ -387,6 +387,7 @@ class ConversationReplies(object):
# dict yet when the adapter is first created # dict yet when the adapter is first created
return self.conversation._children.get(self.comment_id, LLSet()) return self.conversation._children.get(self.comment_id, LLSet())
class CommentReplies(ConversationReplies): class CommentReplies(ConversationReplies):
"""An IReplies adapter for comments. """An IReplies adapter for comments.
@ -418,4 +419,3 @@ class CommentReplies(ConversationReplies):
# Dict API is inherited, written in terms of self.conversation and # Dict API is inherited, written in terms of self.conversation and
# self.children # self.children

View File

@ -71,7 +71,7 @@ class ConversationCatalogTest(unittest.TestCase):
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document" portal_type="Document"
)) ))
self.conversation = conversation self.conversation = conversation
@ -95,7 +95,7 @@ class ConversationCatalogTest(unittest.TestCase):
comment2.reindexObject() comment2.reindexObject()
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document" portal_type="Document"
)) ))
doc1_brain = brains[0] doc1_brain = brains[0]
@ -120,7 +120,7 @@ class ConversationCatalogTest(unittest.TestCase):
comment2.reindexObject() comment2.reindexObject()
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document" portal_type="Document"
)) ))
doc1_brain = brains[0] doc1_brain = brains[0]
@ -132,7 +132,7 @@ class ConversationCatalogTest(unittest.TestCase):
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document" portal_type="Document"
)) ))
doc1_brain = brains[0] doc1_brain = brains[0]
@ -143,7 +143,7 @@ class ConversationCatalogTest(unittest.TestCase):
del self.conversation[self.new_comment1_id] del self.conversation[self.new_comment1_id]
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document" portal_type="Document"
)) ))
doc1_brain = brains[0] doc1_brain = brains[0]

View File

@ -158,7 +158,8 @@ class CommentTest(unittest.TestCase):
comment1.text = "Go to http://www.plone.org" comment1.text = "Go to http://www.plone.org"
comment1.mime_type = 'text/x-web-intelligent' comment1.mime_type = 'text/x-web-intelligent'
self.assertEqual(comment1.getText(), self.assertEqual(comment1.getText(),
'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>') 'Go to <a href="http://www.plone.org" ' +
'rel="nofollow">http://www.plone.org</a>')
def test_getText_w_custom_targetMimetype(self): def test_getText_w_custom_targetMimetype(self):
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')
@ -206,8 +207,7 @@ class CommentTest(unittest.TestCase):
self.assertEqual(1, self.assertEqual(1,
len(comment.workflow_history['comment_review_workflow'])) len(comment.workflow_history['comment_review_workflow']))
self.assertEqual(None, self.assertEqual(None,
comment.workflow_history['comment_review_workflow'][0]\ comment.workflow_history['comment_review_workflow'][0]['action'])
['action'])
self.assertEqual('pending', self.assertEqual('pending',
self.portal.portal_workflow.getInfoFor(comment, 'review_state')) self.portal.portal_workflow.getInfoFor(comment, 'review_state'))
@ -393,5 +393,6 @@ class RepliesTest(unittest.TestCase):
str(new_re_re_re_id), str(new_re_re_re_id),
re_re_re_comment.absolute_url()) re_re_re_comment.absolute_url())
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -9,7 +9,6 @@ from DateTime import DateTime
from zope.component import createObject from zope.component import createObject
from plone.app.testing import TEST_USER_ID, setRoles from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.testing import logout, login
from plone.app.discussion.testing import \ from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_INTEGRATION_TESTING PLONE_APP_DISCUSSION_INTEGRATION_TESTING
@ -108,7 +107,6 @@ class CommentIndexersTest(unittest.TestCase):
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def setUp(self): def setUp(self):
self.portal = self.layer['portal'] self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager']) setRoles(self.portal, TEST_USER_ID, ['Manager'])
@ -141,7 +139,8 @@ class CommentIndexersTest(unittest.TestCase):
def test_description(self): def test_description(self):
self.assertEqual(catalog.description(self.comment)(), self.assertEqual(catalog.description(self.comment)(),
'Lorem ipsum dolor sit amet.') 'Lorem ipsum dolor sit amet.')
self.assertTrue(isinstance(catalog.description, DelegatingIndexerFactory)) self.assertTrue(
isinstance(catalog.description, DelegatingIndexerFactory))
def test_description_long(self): def test_description_long(self):
# Create a 50 word comment and make sure the description returns # Create a 50 word comment and make sure the description returns

View File

@ -66,6 +66,7 @@ class CommentingTool(UniqueObject, SimpleItem):
kw['object_provides'] = object_provides kw['object_provides'] = object_provides
return catalog.searchResults(REQUEST, **kw) return catalog.searchResults(REQUEST, **kw)
def index_object(obj, event): def index_object(obj, event):
"""Index the object when added to the conversation """Index the object when added to the conversation
""" """
@ -73,6 +74,7 @@ def index_object(obj, event):
if tool is not None: if tool is not None:
tool.indexObject(obj) tool.indexObject(obj)
def unindex_object(obj, event): def unindex_object(obj, event):
"""Unindex the object when removed """Unindex the object when removed
""" """