プロジェクト

全般

プロフィール

Vote #80742

完了

Support custom fields when exporting users to CSV

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Accounts / authentication_7
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
7
version_id:
152
issue_org_id:
33126
author_id:
259873
assigned_to_id:
332
comments:
12
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

You can export the users list csv(#5957), but it does not include the value of UserCustomField.
The value of UserCustomField should also be output as csv.


journals

I have attached a patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you for improving Redmine.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
<pre>
Offenses:
app/helpers/users_helper.rb:99:15: C: Style/FormatString: Favor format over sprintf.
sprintf('%.2f', v).gsub('.', l(:general_csv_decimal_separator))
^^^^^^^
889 files inspected, 1 offense detected
</pre>
--------------------------------------------------------------------------------
The following code fixes the Rubocop offence:

<pre><code class="diff">
Index: app/helpers/users_helper.rb
===================================================================
--- app/helpers/users_helper.rb (リビジョン 19642)
+++ app/helpers/users_helper.rb (作業コピー)
@@ -96,7 +96,7 @@
format_object(value, false) do |v|
case v.class.name
when 'Float'
- sprintf('%.2f', v).gsub('.', l(:general_csv_decimal_separator))
+ format('%.2f', v).gsub('.', l(:general_csv_decimal_separator))
else
v
end
</code></pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> The following code fixes the Rubocop offence:
>
> [...]

Yes, this is an option, but @format@ is just an alias of @sprintf@ and it's not used anywhere else in the code. I propose to stick to @sprintf@ and fix this using the following code:
<pre><code class="diff">
mariusbalteanu@Mariuss-MacBook-Pro redmine % git diff
diff --git a/.rubocop.yml b/.rubocop.yml
index 73f1d18f0..4b63e0b5f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -83,6 +83,9 @@ Style/AsciiComments:
Style/EmptyElse:
EnforcedStyle: empty

+Style/FormatString:
+ EnforcedStyle: sprintf
+
Style/FormatStringToken:
Enabled: false
</code></pre>

In another ticket, we should replace in the code the "percent" style used in some files with @sprintf@ and remove the todo from rubocop.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Marius BALTEANU wrote:
> Go MAEDA wrote:
> > The following code fixes the Rubocop offence:
> >
> > [...]
>
> Yes, this is an option, but @format@ is just an alias of @sprintf@ and it's not used anywhere else in the code. I propose to stick to @sprintf@ and fix this using the following code:
> [...]

Done in r19643. Thank you.
--------------------------------------------------------------------------------
I think it is better to sort columns for custom fields according to the position value, as issues CSV do.

<pre><code class="diff">
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 2a72a5db4..264259d5b 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -82,7 +82,7 @@ module UsersHelper
'last_login_on',
'status'
]
- user_custom_fields = UserCustomField.all
+ user_custom_fields = UserCustomField.sorted

# csv header fields
csv << columns.map {|column| l('field_' + column)} + user_custom_fields.pluck(:name)
</code></pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> I think it is better to sort columns for custom fields according to the position value, as issues CSV do.
>
> [...]

Committed the fix in r19767.

--------------------------------------------------------------------------------


related_issues

relates,Closed,5957,Export users list to CSV

Admin Redmine さんが3年以上前に更新

  • カテゴリAccounts / authentication_7 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0