From 5300e33457fc0bb436837597cba19bfbab93fcd9 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sat, 13 Jun 2009 18:02:59 +0000 Subject: [PATCH] fix the anonymous view for the comments viewlet. refactor get_replies. svn path=/plone.app.discussion/trunk/; revision=27410 --- plone/app/discussion/browser/comments.pt | 2 +- plone/app/discussion/browser/comments.py | 34 +++++++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/plone/app/discussion/browser/comments.pt b/plone/app/discussion/browser/comments.pt index ce0c6d5..e1ce214 100644 --- a/plone/app/discussion/browser/comments.pt +++ b/plone/app/discussion/browser/comments.pt @@ -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"> diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 4821ffb..377d4df 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -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: