Skip to content

Commit 2f52ef4

Browse files
committed
Revert "feat: add workflow actions for comments based on their status"
This reverts commit 6d06a1a.
1 parent 269bae0 commit 2f52ef4

1 file changed

Lines changed: 6 additions & 67 deletions

File tree

src/plone/app/discussion/browser/comments.py

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -428,62 +428,6 @@ def has_replies(self, workflow_actions=False):
428428
pass
429429
return False
430430

431-
def get_actions_for_comment(self, comment_obj, workflow_status=None):
432-
"""Get available actions for a comment based on its workflow state.
433-
Returns actions filtered according to the current workflow state.
434-
"""
435-
if workflow_status is None:
436-
wf = getToolByName(self.context, "portal_workflow")
437-
workflow_status = wf.getInfoFor(comment_obj, "review_state")
438-
439-
if workflow_status == "pending":
440-
return self._get_actions_for_pending_comment(comment_obj)
441-
elif workflow_status == "published":
442-
return self._get_actions_for_published_comment(comment_obj)
443-
elif workflow_status in ("rejected", "spam"):
444-
return self._get_actions_for_rejected_comment(comment_obj)
445-
else:
446-
# Fallback to all available actions
447-
return self._get_all_comment_actions(comment_obj)
448-
449-
def _get_all_comment_actions(self, comment_obj):
450-
"""Get all possible workflow actions for a comment."""
451-
wf = getToolByName(self.context, "portal_workflow")
452-
return [
453-
a
454-
for a in wf.listActionInfos(object=comment_obj)
455-
if a["category"] == "workflow" and a["allowed"]
456-
]
457-
458-
def _get_actions_for_pending_comment(self, comment_obj):
459-
"""Get available actions for a pending (unapproved) comment:
460-
- Delete: Permanently remove the comment
461-
- Spam: Mark as spam and hide from moderation queue
462-
- Approve: Publish the comment publicly
463-
"""
464-
actions = self._get_all_comment_actions(comment_obj)
465-
allowed_actions = ["delete", "mark_as_spam", "publish", "reject"]
466-
return [action for action in actions if action["id"] in allowed_actions]
467-
468-
def _get_actions_for_published_comment(self, comment_obj):
469-
"""Get available actions for a published (approved) comment:
470-
- Delete: Permanently remove the comment
471-
- Spam: Mark as spam and unpublish
472-
- Unpublish/Recall: Remove from public view, return to pending state
473-
"""
474-
actions = self._get_all_comment_actions(comment_obj)
475-
allowed_actions = ["delete", "mark_as_spam", "recall"]
476-
return [action for action in actions if action["id"] in allowed_actions]
477-
478-
def _get_actions_for_rejected_comment(self, comment_obj):
479-
"""Get available actions for a rejected/spam comment:
480-
- Delete: Permanently remove
481-
- Approve: Reverse the rejection/spam status and publish
482-
"""
483-
actions = self._get_all_comment_actions(comment_obj)
484-
allowed_actions = ["delete", "publish"]
485-
return [action for action in actions if action["id"] in allowed_actions]
486-
487431
def get_replies(self, workflow_actions=False):
488432
"""Returns all replies to a content object.
489433
@@ -507,13 +451,14 @@ def replies_with_workflow_actions():
507451
# Generator that returns replies dict with workflow actions
508452
for r in conversation.getThreads():
509453
comment_obj = r["comment"]
510-
# Get workflow status
511-
workflow_status = wf.getInfoFor(comment_obj, "review_state")
512-
# Get actions filtered by workflow state
513-
actions = self.get_actions_for_comment(comment_obj, workflow_status)
454+
# list all possible workflow actions
455+
actions = [
456+
a
457+
for a in wf.listActionInfos(object=comment_obj)
458+
if a["category"] == "workflow" and a["allowed"]
459+
]
514460
r = r.copy()
515461
r["actions"] = actions
516-
r["workflow_status"] = workflow_status
517462
yield r
518463

519464
def published_replies():
@@ -524,12 +469,6 @@ def published_replies():
524469
if workflow_status == "published":
525470
r = r.copy()
526471
r["workflow_status"] = workflow_status
527-
# We don't need actions for published replies in the standard view
528-
# but we can add them for consistency
529-
if self.can_review():
530-
r["actions"] = self.get_actions_for_comment(
531-
comment_obj, workflow_status
532-
)
533472
yield r
534473

535474
# Return all direct replies

0 commit comments

Comments
 (0)