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: