mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: adds a /admin/reports route to list all reports
This commit is contained in:
@ -1,6 +1,22 @@
|
||||
require_dependency 'report'
|
||||
|
||||
class Admin::ReportsController < Admin::AdminController
|
||||
def index
|
||||
reports_methods = Report.singleton_methods.grep(/^report_(?!about)/)
|
||||
|
||||
reports = reports_methods.map do |name|
|
||||
type = name.to_s.gsub('report_', '')
|
||||
description = I18n.t("reports.#{type}.description", default: '')
|
||||
|
||||
{
|
||||
type: type,
|
||||
title: I18n.t("reports.#{type}.title"),
|
||||
description: description.presence ? description : nil,
|
||||
}
|
||||
end
|
||||
|
||||
render_json_dump(reports: reports.sort_by { |report| report[:title] })
|
||||
end
|
||||
|
||||
def show
|
||||
report_type = params[:type]
|
||||
|
Reference in New Issue
Block a user