fix the anonymous view for the comments viewlet.

refactor get_replies.

svn path=/plone.app.discussion/trunk/; revision=27410
This commit is contained in:
Timo Stollenwerk 2009-06-13 18:02:59 +00:00
parent c318ecc6c5
commit 5300e33457
2 changed files with 20 additions and 16 deletions

View File

@ -102,7 +102,7 @@
action=""
method="get"
style="display: inline;"
tal:repeat="action reply_dict/actions"
tal:repeat="action reply_dict/actions|nothing"
tal:attributes="action string:${reply/absolute_url}/content_status_modify;
name action/id">
<input type="hidden" name="workflow_action" tal:attributes="value action/id" />

View File

@ -62,30 +62,34 @@ class CommentsViewlet(ViewletBase):
def get_replies(self, workflow_actions=False):
# Acquisition wrap the conversation
# Acquisition wrap the conversation
context = aq_inner(self.context)
conversation = IConversation(context)
conversation = IConversation(context).__of__(context)
def replies_with_workflow_actions():
# Return dict with workflow actions
#context = aq_inner(self.context)
wf = getToolByName(context, 'portal_workflow')
for r in conversation.getThreads():
comment_obj = r['comment']
# list all possible workflow actions
actions = [a for a in wf.listActionInfos(object=comment_obj)
if a['category'] == 'workflow' and a['allowed']]
r = r.copy()
r['actions'] = actions
yield r
# Return all direct replies
if conversation.total_comments > 0:
if workflow_actions:
# Return dict with workflow actions
#context = aq_inner(self.context)
wf = getToolByName(context, 'portal_workflow')
for r in conversation.getThreads():
comment_obj = r['comment']
# list all possible workflow actions
actions = [a for a in wf.listActionInfos(object=comment_obj)
if a['category'] == 'workflow' and a['allowed']]
r = r.copy()
r['actions'] = actions
yield r
return replies_with_workflow_actions()
else:
yield conversation.getThreads()
return conversation.getThreads()
else:
yield []
return None
def get_commenter_home_url(self, username):
if username is None: