Pep8
This commit is contained in:
parent
bbc70ede54
commit
07cde3ca7b
@ -21,7 +21,7 @@ class View(BrowserView):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
# id is not writeable in Zope 2.12
|
# id is not writeable in Zope 2.12
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
self.request.set('disable_border', True)
|
self.request.set('disable_border', True)
|
||||||
context = aq_inner(self.context)
|
context = aq_inner(self.context)
|
||||||
@ -31,7 +31,7 @@ class View(BrowserView):
|
|||||||
sort_on='created',
|
sort_on='created',
|
||||||
sort_order='reverse')
|
sort_order='reverse')
|
||||||
return self.template()
|
return self.template()
|
||||||
|
|
||||||
def moderation_enabled(self):
|
def moderation_enabled(self):
|
||||||
"""Returns true if a 'review workflow' is enabled on 'Discussion Item'
|
"""Returns true if a 'review workflow' is enabled on 'Discussion Item'
|
||||||
content type. A 'review workflow' is characterized by implementing
|
content type. A 'review workflow' is characterized by implementing
|
||||||
@ -39,7 +39,8 @@ class View(BrowserView):
|
|||||||
"""
|
"""
|
||||||
context = aq_inner(self.context)
|
context = aq_inner(self.context)
|
||||||
workflowTool = getToolByName(context, 'portal_workflow')
|
workflowTool = getToolByName(context, 'portal_workflow')
|
||||||
comment_workflow = workflowTool.getChainForPortalType('Discussion Item')
|
comment_workflow = workflowTool.getChainForPortalType(
|
||||||
|
'Discussion Item')
|
||||||
if comment_workflow:
|
if comment_workflow:
|
||||||
comment_workflow = comment_workflow[0]
|
comment_workflow = comment_workflow[0]
|
||||||
comment_workflow = workflowTool[comment_workflow]
|
comment_workflow = workflowTool[comment_workflow]
|
||||||
@ -57,37 +58,38 @@ class ModerateCommentsEnabled(BrowserView):
|
|||||||
"""
|
"""
|
||||||
context = aq_inner(self.context)
|
context = aq_inner(self.context)
|
||||||
workflowTool = getToolByName(context, 'portal_workflow', None)
|
workflowTool = getToolByName(context, 'portal_workflow', None)
|
||||||
comment_workflow = workflowTool.getChainForPortalType('Discussion Item')
|
comment_workflow = workflowTool.getChainForPortalType(
|
||||||
|
'Discussion Item')
|
||||||
if comment_workflow:
|
if comment_workflow:
|
||||||
comment_workflow = comment_workflow[0]
|
comment_workflow = comment_workflow[0]
|
||||||
comment_workflow = workflowTool[comment_workflow]
|
comment_workflow = workflowTool[comment_workflow]
|
||||||
if 'pending' in comment_workflow.states:
|
if 'pending' in comment_workflow.states:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class DeleteComment(BrowserView):
|
class DeleteComment(BrowserView):
|
||||||
"""Delete a comment from a conversation.
|
"""Delete a comment from a conversation.
|
||||||
|
|
||||||
This view is always called directly on the comment object:
|
This view is always called directly on the comment object:
|
||||||
|
|
||||||
http://nohost/front-page/++conversation++default/1286289644723317/\
|
http://nohost/front-page/++conversation++default/1286289644723317/\
|
||||||
@@moderate-delete-comment
|
@@moderate-delete-comment
|
||||||
|
|
||||||
Each table row (comment) in the moderation view contains a hidden input
|
Each table row (comment) in the moderation view contains a hidden input
|
||||||
field with the absolute URL of the content object:
|
field with the absolute URL of the content object:
|
||||||
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
value="http://nohost/front-page/++conversation++default/\
|
value="http://nohost/front-page/++conversation++default/\
|
||||||
1286289644723317"
|
1286289644723317"
|
||||||
name="selected_obj_paths:list">
|
name="selected_obj_paths:list">
|
||||||
|
|
||||||
This absolute URL is called from a jQuery method that is bind to the
|
This absolute URL is called from a jQuery method that is bind to the
|
||||||
'delete' button of the table row. See javascripts/moderation.js for more
|
'delete' button of the table row. See javascripts/moderation.js for more
|
||||||
details.
|
details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
comment = aq_inner(self.context)
|
comment = aq_inner(self.context)
|
||||||
conversation = aq_parent(comment)
|
conversation = aq_parent(comment)
|
||||||
@ -104,25 +106,25 @@ class DeleteComment(BrowserView):
|
|||||||
|
|
||||||
class PublishComment(BrowserView):
|
class PublishComment(BrowserView):
|
||||||
"""Publish a comment.
|
"""Publish a comment.
|
||||||
|
|
||||||
This view is always called directly on the comment object:
|
This view is always called directly on the comment object:
|
||||||
|
|
||||||
http://nohost/front-page/++conversation++default/1286289644723317/\
|
http://nohost/front-page/++conversation++default/1286289644723317/\
|
||||||
@@moderate-publish-comment
|
@@moderate-publish-comment
|
||||||
|
|
||||||
Each table row (comment) in the moderation view contains a hidden input
|
Each table row (comment) in the moderation view contains a hidden input
|
||||||
field with the absolute URL of the content object:
|
field with the absolute URL of the content object:
|
||||||
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
value="http://nohost/front-page/++conversation++default/\
|
value="http://nohost/front-page/++conversation++default/\
|
||||||
1286289644723317"
|
1286289644723317"
|
||||||
name="selected_obj_paths:list">
|
name="selected_obj_paths:list">
|
||||||
|
|
||||||
This absolute URL is called from a jQuery method that is bind to the
|
This absolute URL is called from a jQuery method that is bind to the
|
||||||
'delete' button of the table row. See javascripts/moderation.js for more
|
'delete' button of the table row. See javascripts/moderation.js for more
|
||||||
details.
|
details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
comment = aq_inner(self.context)
|
comment = aq_inner(self.context)
|
||||||
content_object = aq_parent(aq_parent(comment))
|
content_object = aq_parent(aq_parent(comment))
|
||||||
@ -140,29 +142,30 @@ class PublishComment(BrowserView):
|
|||||||
came_from = content_object.absolute_url()
|
came_from = content_object.absolute_url()
|
||||||
return self.context.REQUEST.RESPONSE.redirect(came_from)
|
return self.context.REQUEST.RESPONSE.redirect(came_from)
|
||||||
|
|
||||||
|
|
||||||
class BulkActionsView(BrowserView):
|
class BulkActionsView(BrowserView):
|
||||||
"""Bulk actions (unapprove, approve, delete, mark as spam).
|
"""Bulk actions (unapprove, approve, delete, mark as spam).
|
||||||
|
|
||||||
Each table row of the moderation view has a checkbox with the absolute
|
Each table row of the moderation view has a checkbox with the absolute
|
||||||
path (without host and port) of the comment objects:
|
path (without host and port) of the comment objects:
|
||||||
|
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
name="paths:list"
|
name="paths:list"
|
||||||
value="/plone/front-page/++conversation++default/\
|
value="/plone/front-page/++conversation++default/\
|
||||||
1286289644723317"
|
1286289644723317"
|
||||||
id="cb_1286289644723317" />
|
id="cb_1286289644723317" />
|
||||||
|
|
||||||
If checked, the comment path will occur in the 'paths' variable of
|
If checked, the comment path will occur in the 'paths' variable of
|
||||||
the request when the bulk actions view is called. The bulk action
|
the request when the bulk actions view is called. The bulk action
|
||||||
(delete, publish, etc.) will be applied to all comments that are
|
(delete, publish, etc.) will be applied to all comments that are
|
||||||
included.
|
included.
|
||||||
|
|
||||||
The paths have to be 'traversable':
|
The paths have to be 'traversable':
|
||||||
|
|
||||||
/plone/front-page/++conversation++default/1286289644723317
|
/plone/front-page/++conversation++default/1286289644723317
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
if 'form.select.BulkAction' in self.request:
|
if 'form.select.BulkAction' in self.request:
|
||||||
bulkaction = self.request.get('form.select.BulkAction')
|
bulkaction = self.request.get('form.select.BulkAction')
|
||||||
@ -180,18 +183,18 @@ class BulkActionsView(BrowserView):
|
|||||||
elif bulkaction == 'delete':
|
elif bulkaction == 'delete':
|
||||||
self.delete()
|
self.delete()
|
||||||
else:
|
else:
|
||||||
raise KeyError # pragma: no cover
|
raise KeyError # pragma: no cover
|
||||||
|
|
||||||
def retract(self):
|
def retract(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
"""Publishes all comments in the paths variable.
|
"""Publishes all comments in the paths variable.
|
||||||
|
|
||||||
Expects a list of absolute paths (without host and port):
|
Expects a list of absolute paths (without host and port):
|
||||||
|
|
||||||
/Plone/startseite/++conversation++default/1286200010610352
|
/Plone/startseite/++conversation++default/1286200010610352
|
||||||
|
|
||||||
"""
|
"""
|
||||||
context = aq_inner(self.context)
|
context = aq_inner(self.context)
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
@ -202,17 +205,17 @@ class BulkActionsView(BrowserView):
|
|||||||
workflowTool.doActionFor(comment, 'publish')
|
workflowTool.doActionFor(comment, 'publish')
|
||||||
catalog = getToolByName(comment, 'portal_catalog')
|
catalog = getToolByName(comment, 'portal_catalog')
|
||||||
catalog.reindexObject(comment)
|
catalog.reindexObject(comment)
|
||||||
|
|
||||||
def mark_as_spam(self):
|
def mark_as_spam(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Deletes all comments in the paths variable.
|
"""Deletes all comments in the paths variable.
|
||||||
|
|
||||||
Expects a list of absolute paths (without host and port):
|
Expects a list of absolute paths (without host and port):
|
||||||
|
|
||||||
/Plone/startseite/++conversation++default/1286200010610352
|
/Plone/startseite/++conversation++default/1286200010610352
|
||||||
|
|
||||||
"""
|
"""
|
||||||
context = aq_inner(self.context)
|
context = aq_inner(self.context)
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
|
Loading…
Reference in New Issue
Block a user