From 22a518c921a26f4d2ab9ef642d49a127579d4b4a Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 18 May 2020 11:07:51 +0200 Subject: [PATCH] ajout d'un bouton d'export des mails des demandeurs --- app/controllers/manager/procedures_controller.rb | 7 +++++++ app/views/manager/procedures/show.html.erb | 3 +++ config/routes.rb | 1 + 3 files changed, 11 insertions(+) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index a6c45dbd9..33843a6c1 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -39,6 +39,13 @@ module Manager redirect_to manager_procedure_path(procedure) end + def export_mail_brouillons + dossiers = procedure.dossiers.state_brouillon + emails = dossiers.map { |d| d.user.email }.sort + date = Time.zone.now.strftime('%d-%m-%Y') + send_data(emails.join("\n"), :filename => "brouillons-#{procedure.id}-au-#{date}.csv") + end + def add_administrateur administrateur = Administrateur.by_email(params[:email]) if administrateur diff --git a/app/views/manager/procedures/show.html.erb b/app/views/manager/procedures/show.html.erb index faa058874..cae25c6be 100644 --- a/app/views/manager/procedures/show.html.erb +++ b/app/views/manager/procedures/show.html.erb @@ -71,5 +71,8 @@ as well as a link to its edit page. <% end %> <% end %> +
+ Télécharger un export CSV contenant les emails des demandeurs ayant effectué une demandes en brouillon +
diff --git a/config/routes.rb b/config/routes.rb index bdbcc31a3..3375caf17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Rails.application.routes.draw do post 'restore', on: :member post 'add_administrateur', on: :member post 'change_piece_justificative_template', on: :member + get 'export_mail_brouillons', on: :member end resources :dossiers, only: [:index, :show] do