Allow staff to delete their own comments.#4705
Conversation
wes-otf
left a comment
There was a problem hiding this comment.
looks & works great! just a few super small things
| return render( | ||
| request, | ||
| "activity/partial_comment_message.html", | ||
| {"activity": activity, "success": True}, | ||
| ) |
There was a problem hiding this comment.
What are your thoughts on this:
| 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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
| 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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
Fixes #4606
Test Steps