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,51 +34,50 @@
</metal:scripts> </metal:scripts>
<metal:main fill-slot="main"> <metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main" <tal:main-macro metal:define-macro="main">
tal:define="items view/comments">
<h1 class="documentFirstHeading" i18n:translate="title_review"> <h1 class="documentFirstHeading" i18n:translate="title_review">
Review comments Review comments
</h1> </h1>
<ul class="filter"> <ul class="filter">
<li class="all"> <li class="all">
<form method="post" <form method="post"
action="#" action="#"
tal:attributes="action string:${context/absolute_url}/@@moderate-comments"> tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="submit" value="All" class="context" /> <input type="submit" value="All" class="context" />
</form> </form>
</li> </li>
<li class="pending"> <li class="pending">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments"> <form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.FilterPending" value="1" /> <input type="hidden" name="form.button.FilterPending" value="1" />
<input type="submit" value="Pending" class="context" /> <input type="submit" value="Pending" class="context" />
</form> </form>
</li> </li>
<li class="approved"> <li class="approved">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments"> <form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.FilterPublished" value="1" /> <input type="hidden" name="form.button.FilterPublished" value="1" />
<input type="submit" value="Published" class="context" /> <input type="submit" value="Published" class="context" />
</form> </form>
</li> </li>
<!-- <!--
<li class="spam"> <li class="spam">
<a href="#" <a href="#"
tal:attributes="href string:${context/absolute_url}/@@comments-spam" tal:attributes="href string:${context/absolute_url}/@@comments-spam"
i18n:translate="title_filter_spam">Spam</a> i18n:translate="title_filter_spam">Spam</a>
</li> </li>
--> -->
</ul> </ul>
<form name="folderContentsForm" <form name="folderContentsForm"
method="post" method="post"
action="folder_object" action="folder_object"
tal:attributes="action context/absolute_url" tal:attributes="action context/absolute_url"
class="kssattr-serveraction-foldercontents_update_table"> class="kssattr-serveraction-foldercontents_update_table">
<!-- TODO: change class and replace KSS methods --> <!-- 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" /> <input tal:replace="structure context/@@authenticator/authenticator" />
</form> </form>
<form method="post" <form method="post"
action="#" action="#"
@ -98,9 +97,12 @@
name="form.button.BulkAction" name="form.button.BulkAction"
i18n:attributes="value label_apply;" /> 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> <thead>
<!--
<tr tal:condition="not:view/table/selectcurrentbatch"> <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> <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> </tr>
@ -126,6 +128,7 @@
id="foldercontents-clearselection" class="update-selection">Clear selection</a> id="foldercontents-clearselection" class="update-selection">Clear selection</a>
</th> </th>
</tr> </tr>
-->
<tr> <tr>
<th class="nosort"> </th> <th class="nosort"> </th>
<th i18n:translate="heading_author">Commenter</th> <th i18n:translate="heading_author">Commenter</th>
@ -197,6 +200,7 @@
</tr> </tr>
</tal:block> </tal:block>
</tbody> </tbody>
<!--
<tfooter tal:condition="not:view/table/within_batch_size"> <tfooter tal:condition="not:view/table/within_batch_size">
<tr tal:condition="not:view/table/show_all"> <tr tal:condition="not:view/table/show_all">
<th colspan="7" class="nosort"> <th colspan="7" class="nosort">
@ -213,9 +217,9 @@
</th> </th>
</tr> </tr>
</tfooter> </tfooter>
-->
</table> </table>
-->
</form> </form>
</tal:main-macro> </tal:main-macro>
</metal:main> </metal:main>

View File

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

View File

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

View File

@ -162,15 +162,15 @@
&#9660; &#9660;
</a> </a>
</td> </td>
<td style="width: 11em"> <td style="width: 11.5em">
<form action="" <form action=""
class="background-form" class="background-form moderate-publish-comment"
method="post" method="post"
style="display: inline" style="display: inline"
tal:attributes="action string:${item/url}/@@moderate-publish-comment" 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="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" /> todo string:view/transition" />
<input class="context comment-publish-button" <input class="context comment-publish-button"
type="submit" type="submit"
@ -180,7 +180,7 @@
</form> </form>
<form action="" <form action=""
method="post" method="post"
class="background-form" class="background-form moderate-delete-comment"
style="display: inline" style="display: inline"
tal:attributes="action string:${item/url}/@@moderate-delete-comment"> tal:attributes="action string:${item/url}/@@moderate-delete-comment">
<input type="hidden" name="comment_id" tal:attributes="value item/id" /> <input type="hidden" name="comment_id" tal:attributes="value item/id" />