From ffcdfc22e59eaa76ff4385380fe32196620e518d Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Fri, 26 Jun 2009 18:59:37 +0000 Subject: [PATCH] bulk actions for publish and delete added. svn path=/plone.app.discussion/trunk/; revision=27674 --- plone/app/discussion/browser/moderation.pt | 25 +++++++------ plone/app/discussion/browser/moderation.py | 42 ++++++++++++++++++++-- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/plone/app/discussion/browser/moderation.pt b/plone/app/discussion/browser/moderation.pt index bccb795..3d5ee72 100644 --- a/plone/app/discussion/browser/moderation.pt +++ b/plone/app/discussion/browser/moderation.pt @@ -70,23 +70,26 @@ --> -
- - - - + + + -
- + +
+ alt string:Select ${item/Title}; + title string:Select ${item/Title}" /> @@ -172,7 +175,7 @@
- + diff --git a/plone/app/discussion/browser/moderation.py b/plone/app/discussion/browser/moderation.py index d76508b..f144831 100644 --- a/plone/app/discussion/browser/moderation.py +++ b/plone/app/discussion/browser/moderation.py @@ -121,5 +121,43 @@ class BulkActionsView(BrowserView): if self.request.has_key('form.button.BulkAction'): - bulkaction = self.request.get('form.bulkaction') - return bulkaction + bulkaction = self.request.get('form.select.BulkAction') + + paths = self.request.get('paths') + + if bulkaction == '-1': + return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER) + elif bulkaction == 'retract': + self.retract(paths) + elif bulkaction == 'publish': + self.publish(paths) + elif bulkaction == 'mark_as_spam': + self.mark_as_spam(paths) + elif bulkaction == 'delete': + self.delete(paths) + else: + raise KeyError + + return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER) + + def retract(self, paths): + raise NotImplementedError + + def publish(self, paths): + context = aq_inner(self.context) + for path in paths: + comment = context.restrictedTraverse(path) + portal_workflow = getToolByName(comment, 'portal_workflow') + portal_workflow.doActionFor(comment, 'publish') + catalog = getToolByName(comment, 'portal_catalog') + catalog.reindexObject(comment) + + def mark_as_spam(self, paths): + raise NotImplementedError + + def delete(self, paths): + context = aq_inner(self.context) + for path in paths: + comment = context.restrictedTraverse(path) + conversation = aq_parent(comment) + del conversation[comment.id]