Add a task to destroy, regenerate, and send new attestations
For dossiers that were accepté, went back to en instruction, and then were accepté again
This commit is contained in:
parent
ead4a6a2fd
commit
478598f74c
2 changed files with 77 additions and 0 deletions
33
app/mailers/new_attestation_mailer.rb
Normal file
33
app/mailers/new_attestation_mailer.rb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
module Mailers
|
||||||
|
class NewAttestationMailer < ApplicationMailer
|
||||||
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
|
def new_attestation(dossier)
|
||||||
|
to = dossier.user.email
|
||||||
|
subject = "Nouvelle attestation pour votre dossier nº #{dossier.id}"
|
||||||
|
|
||||||
|
mail(to: to, subject: subject, body: body(dossier))
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def body(dossier)
|
||||||
|
<<~HEREDOC
|
||||||
|
Bonjour,
|
||||||
|
|
||||||
|
Votre dossier nº #{dossier.id} (procédure "#{dossier.procedure.libelle}") a subi, à un moment, un "aller-retour" :
|
||||||
|
- Acceptation de votre dossier
|
||||||
|
- Passage en instruction du dossier car besoin de le modifier
|
||||||
|
- Seconde acceptation de votre dossier
|
||||||
|
|
||||||
|
Suite à cette opération, l'attestation liée à votre dossier n'a pas été regénérée.
|
||||||
|
Ce problème est désormais reglé, votre nouvelle attestation est disponible à l'adresse suivante :
|
||||||
|
#{dossier_attestation_url(dossier)}
|
||||||
|
|
||||||
|
Cordialement,
|
||||||
|
|
||||||
|
L’équipe demarches-simplifiees.fr
|
||||||
|
HEREDOC
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
44
lib/tasks/2018_06_05_send_new_attestations.rake
Normal file
44
lib/tasks/2018_06_05_send_new_attestations.rake
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
namespace :'2018_06_05_send_new_attestation' do
|
||||||
|
task set: :environment do
|
||||||
|
ids = [
|
||||||
|
20982,
|
||||||
|
21262,
|
||||||
|
54914,
|
||||||
|
59769,
|
||||||
|
63747,
|
||||||
|
59520,
|
||||||
|
21496,
|
||||||
|
13386,
|
||||||
|
13371,
|
||||||
|
14585,
|
||||||
|
15307,
|
||||||
|
17212,
|
||||||
|
16037,
|
||||||
|
60403,
|
||||||
|
60400,
|
||||||
|
20534,
|
||||||
|
60123,
|
||||||
|
16361,
|
||||||
|
16359,
|
||||||
|
57147,
|
||||||
|
51979,
|
||||||
|
49632,
|
||||||
|
48628,
|
||||||
|
48624,
|
||||||
|
22077,
|
||||||
|
41103
|
||||||
|
]
|
||||||
|
|
||||||
|
dossiers = ids.map { |id| Dossier.Dossier.find_by(id: id) }.compact
|
||||||
|
|
||||||
|
dossiers.each do |dossier|
|
||||||
|
attestation = dossier.attestation
|
||||||
|
attestation.destroy
|
||||||
|
|
||||||
|
dossier.attestation = dossier.build_attestation
|
||||||
|
|
||||||
|
Mailers::NewAttestationMailer.new_attestation(dossier).deliver_later
|
||||||
|
puts "Email envoyé à #{email} pour le dossier #{dossier.id}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue