FEATURE: Display pending posts on user’s page

Currently when a user creates posts that are moderated (for whatever
reason), a popup is displayed saying the post needs approval and the
total number of the user’s pending posts. But then this piece of
information is kind of lost and there is nowhere for the user to know
what are their pending posts or how many there are.

This patch solves this issue by adding a new “Pending” section to the
user’s activity page when there are some pending posts to display. When
there are none, then the “Pending” section isn’t displayed at all.
This commit is contained in:
Loïc Guitaut
2021-08-26 18:16:00 +02:00
committed by Loïc Guitaut
parent 6e603799eb
commit a5fbb90df4
49 changed files with 737 additions and 110 deletions

View File

@ -598,6 +598,14 @@ class PostsController < ApplicationController
render_serialized(posts, AdminUserActionSerializer)
end
def pending
params.require(:username)
user = fetch_user_from_params
raise Discourse::NotFound unless guardian.can_edit_user?(user)
render_serialized(user.pending_posts.order(created_at: :desc), PendingPostSerializer, root: :pending_posts)
end
protected
# We can't break the API for making posts. The new, queue supporting API