bulk actions for publish and delete added.
svn path=/plone.app.discussion/trunk/; revision=27674
This commit is contained in:
parent
e0da88efba
commit
ffcdfc22e5
@ -70,23 +70,26 @@
|
|||||||
-->
|
-->
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<form method="post" action="#" tal:attributes="action context/absolute_url">
|
<form method="post"
|
||||||
<select name="bulkaction">
|
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 selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option>
|
||||||
<option value="unapprove" i18n:translate="bulkactions_unapprove">Unapprove</option>
|
<!--<option value="retract" i18n:translate="bulkactions_retract">Retract</option>-->
|
||||||
<option value="approve" i18n:translate="bulkactions_approve">Approve</option>
|
<option value="publish" i18n:translate="bulkactions_publish">Publish</option>
|
||||||
<option value="markasspam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>
|
<!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>-->
|
||||||
<option value="delete" i18n:translate="bulkactions_delete">Delete</option>
|
<option value="delete" i18n:translate="bulkactions_delete">Delete</option>
|
||||||
</select>
|
</select>
|
||||||
<input id="dobulkaction"
|
<input id="dobulkaction"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="standalone"
|
class="standalone allowMultiSubmit"
|
||||||
value="Apply"
|
value="Apply"
|
||||||
name="form.button.BulkAction"
|
name="form.button.BulkAction"
|
||||||
i18n:attributes="value label_apply;" />
|
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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="7" class="nosort"
|
<th colspan="7" class="nosort"
|
||||||
@ -123,8 +126,8 @@
|
|||||||
tal:attributes="value item/getPath;
|
tal:attributes="value item/getPath;
|
||||||
id string:cb_${item/id};
|
id string:cb_${item/id};
|
||||||
checked item/checked|nothing;
|
checked item/checked|nothing;
|
||||||
alt string:Select ${item/title_or_id};
|
alt string:Select ${item/Title};
|
||||||
title string:Select ${item/title_or_id}" />
|
title string:Select ${item/Title}" />
|
||||||
<input type="hidden" name="selected_obj_paths:list" value="#"
|
<input type="hidden" name="selected_obj_paths:list" value="#"
|
||||||
tal:attributes="value item/getURL" />
|
tal:attributes="value item/getURL" />
|
||||||
</td>
|
</td>
|
||||||
@ -172,7 +175,7 @@
|
|||||||
</tal:block>
|
</tal:block>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
</tal:main-macro>
|
</tal:main-macro>
|
||||||
</metal:main>
|
</metal:main>
|
||||||
|
|
||||||
|
@ -121,5 +121,43 @@ class BulkActionsView(BrowserView):
|
|||||||
|
|
||||||
if self.request.has_key('form.button.BulkAction'):
|
if self.request.has_key('form.button.BulkAction'):
|
||||||
|
|
||||||
bulkaction = self.request.get('form.bulkaction')
|
bulkaction = self.request.get('form.select.BulkAction')
|
||||||
return 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]
|
||||||
|
Loading…
Reference in New Issue
Block a user