fix publish comment button.

svn path=/plone.app.discussion/trunk/; revision=27702
This commit is contained in:
Timo Stollenwerk 2009-06-28 18:29:01 +00:00
parent abb0334c1d
commit 14b00ff361
4 changed files with 93 additions and 70 deletions

View File

@ -34,8 +34,7 @@
</metal:scripts>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="items view/comments">
<tal:main-macro metal:define-macro="main">
<h1 class="documentFirstHeading" i18n:translate="title_review">
Review comments
@ -76,7 +75,7 @@
tal:attributes="action context/absolute_url"
class="kssattr-serveraction-foldercontents_update_table">
<!-- TODO: change class and replace KSS methods -->
<div tal:replace="structure view/contents_table"></div>
<div tal:replace="structure view/comments_table"></div>
<input tal:replace="structure context/@@authenticator/authenticator" />
</form>
@ -98,9 +97,12 @@
name="form.button.BulkAction"
i18n:attributes="value label_apply;" />
<!--
<table id="review-comments" class="listing" style="width: 100%" tal:condition="items">
<table id="review-comments" class="listing" style="width: 100%"
tal:define="items view/comments"
tal:condition="items">
<thead>
<!--
<tr tal:condition="not:view/table/selectcurrentbatch">
<th colspan="7" class="nosort"><span i18n:translate="label_select" tal:omit-tag="">Select:</span> <a i18n:translate="label_all" tal:attributes="href view/table/selectscreen_url" id="foldercontents-selectall" class="update-selection">All</a></th>
</tr>
@ -126,6 +128,7 @@
id="foldercontents-clearselection" class="update-selection">Clear selection</a>
</th>
</tr>
-->
<tr>
<th class="nosort"> </th>
<th i18n:translate="heading_author">Commenter</th>
@ -197,6 +200,7 @@
</tr>
</tal:block>
</tbody>
<!--
<tfooter tal:condition="not:view/table/within_batch_size">
<tr tal:condition="not:view/table/show_all">
<th colspan="7" class="nosort">
@ -213,9 +217,9 @@
</th>
</tr>
</tfooter>
-->
</table>
-->
</form>
</tal:main-macro>
</metal:main>

View File

@ -35,14 +35,14 @@ class View(BrowserView):
template = ViewPageTemplateFile('moderation.pt')
def contents_table(self):
table = ReviewCommentsTable(aq_inner(self.context), self.request)
return table.render()
def __call__(self):
context = aq_inner(self.context)
self.state = self.request.get('review_state', 'pending')
self.transition = self.request.get('publish_transition', 'pending')
self.limit = self.request.get('limit', 100)
if self.request.has_key('form.button.FilterPending'):
self.comments = self.comments_pending()
elif self.request.has_key('form.button.FilterPublished'):
@ -51,11 +51,9 @@ class View(BrowserView):
self.comments = self.comments_all()
return self.template()
def cook(self, text):
return text
def comments_workflow_enabled(self):
return True
def comments_table(self):
table = ReviewCommentsTable(aq_inner(self.context), self.request, self.comments, self.transition)
return table.render()
def comments_all(self, start=0, size=None):
@ -106,6 +104,12 @@ class View(BrowserView):
def comments_spam(self, start=0, size=None):
return None
def cook(self, text):
return text
def comments_workflow_enabled(self):
return True
class ReviewTable(Table):
render = VPTF("table.pt")
batching = VPTF("batching.pt")
@ -114,10 +118,12 @@ class ReviewCommentsTable(object):
"""The reviewcomments table renders the table and its actions.
"""
def __init__(self, context, request, contentFilter={}):
def __init__(self, context, request, content, transition, contentFilter={}, ):
self.context = context
self.request = request
self.contentFilter = contentFilter
self.content = content
self.transition = transition
url = context.absolute_url()
view_url = url + '/@@moderate-comments'
@ -132,17 +138,19 @@ class ReviewCommentsTable(object):
"""
context = aq_inner(self.context)
self.state = self.request.get('review_state', 'pending')
self.transition = self.request.get('publish_transition', 'pending')
self.limit = self.request.get('limit', 100)
#self.state = self.request.get('review_state', 'pending')
#self.transition = self.request.get('publish_transition', 'pending')
#self.limit = self.request.get('limit', 100)
catalog = getToolByName(context, 'portal_catalog')
#catalog = getToolByName(context, 'portal_catalog')
brains = catalog(
portal_type='Discussion Item',
sort_on='created',
sort_limit=self.limit,
)
#brains = catalog(
# portal_type='Discussion Item',
# sort_on='created',
# sort_limit=self.limit,
# )
brains = self.content
plone_utils = getToolByName(context, 'plone_utils')
plone_view = getMultiAdapter((context, self.request), name=u'plone')
@ -206,6 +214,7 @@ class ReviewCommentsTable(object):
icon = icon.html_tag(),
type_class = type_class,
wf_state = review_state,
transition = self.transition,
state_title = portal_workflow.getTitleForStateOnType(review_state,
obj_type),
state_class = state_class,
@ -238,10 +247,12 @@ class ReviewCommentsTable(object):
@property
def buttons(self):
buttons = []
context = aq_inner(self.context)
portal_actions = getToolByName(context, 'portal_actions')
button_actions = portal_actions.listActionInfos(object=context, categories=('folder_buttons', ))
#button_actions = portal_actions.listActionInfos(object=context, categories=('folder_buttons', ))
button_actions = portal_actions.listActionInfos(object=context)
# Do not show buttons if there is no data, unless there is data to be
# pasted

View File

@ -68,3 +68,11 @@ ul.filter {
#dobulkaction {
margin: 0.2em 0;
}
.moderate-publish-comment {
float: left;
}
.moderate-delete-comment {
float: right;
}

View File

@ -162,15 +162,15 @@
&#9660;
</a>
</td>
<td style="width: 11em">
<td style="width: 11.5em">
<form action=""
class="background-form"
class="background-form moderate-publish-comment"
method="post"
style="display: inline"
tal:attributes="action string:${item/url}/@@moderate-publish-comment"
tal:condition="python:True or item.wf_state == 'pending'">
tal:condition="python:item['wf_state'] == 'pending'">
<input type="hidden" name="comment_id" tal:attributes="value item/id" />
<input type="hidden" name="workflow_action" tal:attributes="value string:publish
<input type="hidden" name="workflow_action" tal:attributes="value string:publish;
todo string:view/transition" />
<input class="context comment-publish-button"
type="submit"
@ -180,7 +180,7 @@
</form>
<form action=""
method="post"
class="background-form"
class="background-form moderate-delete-comment"
style="display: inline"
tal:attributes="action string:${item/url}/@@moderate-delete-comment">
<input type="hidden" name="comment_id" tal:attributes="value item/id" />