~crocmagnon/blog

1fa73b90fbfd0cb50740c15214d1787c529bc38e — Gabriel Augendre 6 months ago fbfceec
Add message when approving/rejecting comments
1 files changed, 4 insertions(+), 2 deletions(-)

M articles/admin.py
M articles/admin.py => articles/admin.py +4 -2
@@ 122,7 122,9 @@ class CommentAdmin(admin.ModelAdmin):
    actions = ["approve_comments", "reject_comments"]

    def approve_comments(self, request, queryset):
        queryset.update(status=Comment.APPROVED)
        count = queryset.update(status=Comment.APPROVED)
        messages.success(request, f"Approved {count} message(s).")

    def reject_comments(self, request, queryset):
        queryset.update(status=Comment.REJECTED)
        count = queryset.update(status=Comment.REJECTED)
        messages.success(request, f"Rejected {count} message(s).")