Skip to content

Allow staff to delete their own comments.#4705

Merged
frjo merged 3 commits into
mainfrom
feature/staff-delete-comments
Feb 19, 2026
Merged

Allow staff to delete their own comments.#4705
frjo merged 3 commits into
mainfrom
feature/staff-delete-comments

Conversation

@frjo

@frjo frjo commented Feb 18, 2026

Copy link
Copy Markdown
Member

Fixes #4606

Skärmavbild 2026-02-18 kl  21 57 39

Test Steps

  • Check if staff, and only staff, can delete their own comments.

@frjo frjo added Type: Feature This is something new (not an enhancement of an existing thing). Type: Minor Minor change, used in release drafter labels Feb 18, 2026
@frjo frjo requested a review from wes-otf February 18, 2026 20:56

@wes-otf wes-otf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks & works great! just a few super small things

Comment on lines +93 to +97
return render(
request,
"activity/partial_comment_message.html",
{"activity": activity, "success": True},
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on this:

Suggested change
return render(
request,
"activity/partial_comment_message.html",
{"activity": activity, "success": True},
)
response = render(
request,
"activity/partial_comment_message.html",
{"activity": activity, "success": True},
)
response.headers["HX-Trigger"] = json.dumps({"commentsUpdated": None})
return response

Combined with a new listener in comments.html

 hx-trigger="load, intersect once, commentsUpdated"

Just so the comment auto-updates and tosses the delete/edit buttons on delete

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I have now set target to comment item instead of comment text to get this result. This has the same result but we do not need to reload all activities.

hx-target="#text-comment-{{activity.id}}"
hx-confirm="{% trans "Are you sure you want to delete this comment? This action cannot be undone." %}"
title="{% trans "Delete comment" %}"
class="btn btn-error btn-sm btn-soft btn-square"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class="btn btn-error btn-sm btn-soft btn-square"
class="btn btn-error btn-sm btn-ghost btn-square"

super unimportant but just matches the edit button a little better

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the change, the trash icon then becomes black but on hover you get a red background.

… Use class gohst to mimic edit button. Set target to comment item instead of comment text so buttons gets removed directly when deleting comment.
ActivityAdapter.messages[MESSAGES.UNARCHIVE_SUBMISSION],
]

Activity = apps.get_model("activity", "Activity")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never use the model directly in a migration. If you later on add fields etc. the migrations will fail. Instead use get_model() like above.

@wes-otf wes-otf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@frjo frjo merged commit 074576a into main Feb 19, 2026
7 checks passed
@frjo frjo deleted the feature/staff-delete-comments branch April 10, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature This is something new (not an enhancement of an existing thing). Type: Minor Minor change, used in release drafter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the ability for staff to delete comments

2 participants