Merge pull request #10489 from tchak/feat-export-administration-info
feat(manager): export administrators and instructeurs list
This commit is contained in:
commit
d609b6b71f
5 changed files with 38 additions and 0 deletions
|
@ -35,6 +35,21 @@ module Manager
|
|||
redirect_to manager_administrateurs_path
|
||||
end
|
||||
|
||||
def data_exports
|
||||
end
|
||||
|
||||
def export_last_month
|
||||
administrateurs = Administrateur.joins(:user).where(created_at: 6.months.ago..).where.not(users: { email_verified_at: nil })
|
||||
csv = CSV.generate(headers: true) do |csv|
|
||||
csv << ['ID', 'Email', 'Date de création']
|
||||
administrateurs.each do |administrateur|
|
||||
csv << [administrateur.id, administrateur.email, administrateur.created_at]
|
||||
end
|
||||
end
|
||||
|
||||
send_data csv, filename: "administrateurs_#{Date.today.strftime('%d-%m-%Y')}.csv"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_administrateur_params
|
||||
|
|
|
@ -20,5 +20,17 @@ module Manager
|
|||
|
||||
redirect_to manager_instructeurs_path
|
||||
end
|
||||
|
||||
def export_last_month
|
||||
instructeurs = Instructeur.joins(:user).where(created_at: 6.months.ago..).where.not(users: { email_verified_at: nil })
|
||||
csv = CSV.generate(headers: true) do |csv|
|
||||
csv << ['ID', 'Email', 'Date de création']
|
||||
instructeurs.each do |instructeur|
|
||||
csv << [instructeur.id, instructeur.email, instructeur.created_at]
|
||||
end
|
||||
end
|
||||
|
||||
send_data csv, filename: "instructeurs_#{Date.today.strftime('%d-%m-%Y')}.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
app/views/manager/administrateurs/data_exports.html.erb
Normal file
6
app/views/manager/administrateurs/data_exports.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div>
|
||||
<ul>
|
||||
<li><a href="/manager/exports/administrateurs/last_month">Export des administrateurs (6 mois)</a></li>
|
||||
<li><a href="/manager/exports/instructeurs/last_month">Export des instructeurs (6 mois)</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -29,6 +29,7 @@ as defined by the routes in the `admin/` namespace
|
|||
<%= link_to "Features", manager_flipper_path, class: "navigation__link" %>
|
||||
<%= link_to "Annonces", super_admins_release_notes_path, class: "navigation__link" %>
|
||||
<%= link_to "Import data via CSV", manager_import_procedure_tags_path, class: "navigation__link" %>
|
||||
<%= link_to "Export CSV data", manager_data_exports_path, class: "navigation__link" %>
|
||||
<% if Rails.application.secrets.sendinblue[:enabled] && ENV["SAML_IDP_ENABLED"] == "enabled" %>
|
||||
<%= link_to "Sendinblue", ENV.fetch("SENDINBLUE_LOGIN_URL"), class: "navigation__link", target: '_blank' %>
|
||||
<% end %>
|
||||
|
|
|
@ -110,6 +110,10 @@ Rails.application.routes.draw do
|
|||
mount Sidekiq::Web => "/sidekiq"
|
||||
end
|
||||
|
||||
get 'data_exports' => 'administrateurs#data_exports'
|
||||
get 'exports/administrateurs/last_month' => 'administrateurs#export_last_month'
|
||||
get 'exports/instructeurs/last_month' => 'instructeurs#export_last_month'
|
||||
|
||||
get 'import_procedure_tags' => 'procedures#import_data'
|
||||
post 'import_tags' => 'procedures#import_tags'
|
||||
root to: "administrateurs#index"
|
||||
|
|
Loading…
Reference in a new issue