diff options
author | Go MAEDA <maeda@farend.jp> | 2020-11-13 01:08:15 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-11-13 01:08:15 +0000 |
commit | 167637730dbf2e45ac33f6808517c8138050470d (patch) | |
tree | 61e8eac5341d3e54be67158358bf39a87de50bb5 /app/helpers/users_helper.rb | |
parent | a20eb9b7647d71f0ee5751fdee4113a0de1fc2e9 (diff) | |
download | redmine-167637730dbf2e45ac33f6808517c8138050470d.tar.gz redmine-167637730dbf2e45ac33f6808517c8138050470d.zip |
Include twofa_scheme (two-factor scheme) column when exporting users to CSV (#34241).
Patch by Mizuki ISHIKAWA.
git-svn-id: http://svn.redmine.org/redmine/trunk@20350 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/users_helper.rb')
-rw-r--r-- | app/helpers/users_helper.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 1f5841199..32890ded3 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -78,6 +78,21 @@ module UsersHelper tabs end + def csv_content(column_name, user) + case column_name + when 'status' + l("status_#{User::LABEL_BY_STATUS[user.status]}") + when 'twofa_scheme' + if user.twofa_active? + l("twofa__#{user.twofa_scheme}__name") + else + l(:label_disabled) + end + else + user.send(column_name) + end + end + def users_to_csv(users) Redmine::Export::CSV.generate(:encoding => params[:encoding]) do |csv| columns = [ @@ -87,6 +102,7 @@ module UsersHelper 'mail', 'admin', 'status', + 'twofa_scheme', 'created_on', 'updated_on', 'last_login_on', @@ -99,7 +115,7 @@ module UsersHelper # csv lines users = users.preload(:custom_values) users.each do |user| - values = columns.map {|c| c == 'status' ? l("status_#{User::LABEL_BY_STATUS[user.status]}") : user.send(c)} + + values = columns.map {|c| csv_content(c, user)} + user_custom_fields.map {|custom_field| user.custom_value_for(custom_field)} csv << values.map do |value| |