mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Display the reason for many reviewable items
Queued Posts and Users will now display a reason why they are in the review queue.
This commit is contained in:
@@ -2,7 +2,7 @@ require_dependency 'reviewable_score_type_serializer'
|
||||
|
||||
class ReviewableScoreSerializer < ApplicationSerializer
|
||||
|
||||
attributes :id, :score, :agree_stats, :status, :created_at, :reviewed_at
|
||||
attributes :id, :score, :agree_stats, :status, :reason, :created_at, :reviewed_at
|
||||
has_one :user, serializer: BasicUserSerializer, root: 'users'
|
||||
has_one :score_type, serializer: ReviewableScoreTypeSerializer
|
||||
has_one :reviewable_conversation, serializer: ReviewableConversationSerializer
|
||||
@@ -16,4 +16,28 @@ class ReviewableScoreSerializer < ApplicationSerializer
|
||||
}
|
||||
end
|
||||
|
||||
def reason
|
||||
return unless object.reason
|
||||
|
||||
if text = I18n.t("reviewables.reasons.#{object.reason}", default: nil)
|
||||
# Create a convenient link to any site settings if the user is staff
|
||||
settings_url = "#{Discourse.base_uri}/admin/site_settings/category/all_results?filter="
|
||||
|
||||
text.gsub!(/`[a-z_]+`/) do |m|
|
||||
if scope.is_staff?
|
||||
setting = m[1..-2]
|
||||
"<a href=\"#{settings_url}#{setting}\">#{setting.gsub('_', ' ')}</a>"
|
||||
else
|
||||
m.gsub('_', ' ')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text
|
||||
end
|
||||
|
||||
def include_reason?
|
||||
reason.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user