docbrown/app/views/admin/users/export.csv.erb
Ridhwana aff29406ac
First version of exporting the Users to a CSV (#17217)
* feat: add the export route

* feat: base export csv

* refactor: move the svg into its own file

* feat: add the export partial

* feat: export teh correct fields etc. for the csv

* user status helper

* feat: ensure that we format the time

* feat: add a spec for the CSV

* remove space

* remove puts

* chore: remove blank space

* feat: update traits

* Update app/views/admin/users/export.csv.erb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Update spec/requests/admin/users/users_export_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Update spec/requests/admin/users/users_export_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* fix: export should not error for unregistered users

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2022-04-12 15:24:32 +02:00

6 lines
No EOL
427 B
Text

<%- headers = ["Name", "Username", "Email address", "Status", "Joining date", "Last activity", "Organizations"] -%>
<%= CSV.generate_line headers -%>
<%- @users.each do |user| -%>
<%- row = [user.name, user.username, user.email, user_status(user), user.registered_at&.strftime("%d %b, %Y"), user.last_activity&.strftime("%d %b, %Y"), user.organizations.pluck(:name)] -%>
<%= CSV.generate_line(row).html_safe -%>
<%- end -%>