mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 20:45:51 +00:00
Refactors `TrustLevel` and moves translations from server to client Additional changes: * "staff" and "admin" wasn't translatable in site settings * it replaces a concatenated string with a translation * uses translation for trust levels in users_by_trust_level report * adds a DB migration to rename keys of translation overrides affected by this commit
34 lines
806 B
Ruby
34 lines
806 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Reports::UsersByTrustLevel
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
def report_users_by_trust_level(report)
|
|
report.data = []
|
|
|
|
report.modes = [:table]
|
|
|
|
report.dates_filtering = false
|
|
|
|
report.labels = [
|
|
{
|
|
property: :key,
|
|
title: I18n.t("reports.users_by_trust_level.labels.level")
|
|
},
|
|
{
|
|
property: :y,
|
|
type: :number,
|
|
title: I18n.t("reports.default.labels.count")
|
|
}
|
|
]
|
|
|
|
User.real.group('trust_level').count.sort.each do |level, count|
|
|
key = TrustLevel.name(level.to_i)
|
|
url = Proc.new { |k| "/admin/users/list/#{k}" }
|
|
report.data << { url: url.call(key), key: key, x: level.to_i, y: count }
|
|
end
|
|
end
|
|
end
|
|
end
|