bulk actions for publish and delete added.

svn path=/plone.app.discussion/trunk/; revision=27674
This commit is contained in:
Timo Stollenwerk 2009-06-26 18:59:37 +00:00
parent e0da88efba
commit ffcdfc22e5
2 changed files with 54 additions and 13 deletions

View File

@ -70,23 +70,26 @@
-->
</ul>
<form method="post" action="#" tal:attributes="action context/absolute_url">
<select name="bulkaction">
<form method="post"
action="#"
class="kssattr-serveraction-foldercontents_update_table"
tal:attributes="action string:${context/absolute_url}/@@bulk-actions">
<select name="form.select.BulkAction">
<option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option>
<option value="unapprove" i18n:translate="bulkactions_unapprove">Unapprove</option>
<option value="approve" i18n:translate="bulkactions_approve">Approve</option>
<option value="markasspam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>
<!--<option value="retract" i18n:translate="bulkactions_retract">Retract</option>-->
<option value="publish" i18n:translate="bulkactions_publish">Publish</option>
<!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>-->
<option value="delete" i18n:translate="bulkactions_delete">Delete</option>
</select>
<input id="dobulkaction"
type="submit"
class="standalone"
class="standalone allowMultiSubmit"
value="Apply"
name="form.button.BulkAction"
i18n:attributes="value label_apply;" />
</form>
<table id="review-comments" class="listing nosort" style="width: 100%" tal:condition="items">
<table id="review-comments" class="listing" style="width: 100%" tal:condition="items">
<thead>
<tr>
<th colspan="7" class="nosort"
@ -123,8 +126,8 @@
tal:attributes="value item/getPath;
id string:cb_${item/id};
checked item/checked|nothing;
alt string:Select ${item/title_or_id};
title string:Select ${item/title_or_id}" />
alt string:Select ${item/Title};
title string:Select ${item/Title}" />
<input type="hidden" name="selected_obj_paths:list" value="#"
tal:attributes="value item/getURL" />
</td>
@ -172,7 +175,7 @@
</tal:block>
</tbody>
</table>
</form>
</tal:main-macro>
</metal:main>

View File

@ -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]