Merge pull request #5167 from betagouv/export-brouillons

Ajout d'un bouton d'export des mails des demandeurs
This commit is contained in:
Keirua 2020-05-18 14:55:47 +02:00 committed by GitHub
commit 23316b6e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View file

@ -39,6 +39,13 @@ module Manager
redirect_to manager_procedure_path(procedure)
end
def export_mail_brouillons
dossiers = procedure.dossiers.state_brouillon.includes(:user)
emails = dossiers.map { |d| d.user.email }.sort.uniq
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

View file

@ -71,5 +71,8 @@ as well as a link to its edit page.
<% end %>
</dd>
<% end %>
<dd class="attribute-data">
<a class="button" href="<%= export_mail_brouillons_manager_procedure_url(procedure) %>">Télécharger un export CSV contenant les emails des demandeurs ayant effectué une demandes en brouillon</a>
</dd>
</dl>
</section>

View file

@ -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