FEATURE: adds a /admin/reports route to list all reports

This commit is contained in:
Joffrey JAFFEUX
2018-06-18 12:31:56 +02:00
committed by GitHub
parent 4b604b1e68
commit f2dbe66367
14 changed files with 129 additions and 8 deletions

View File

@ -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]