2018-06-12 18:17:37 +02:00
|
|
|
require Rails.root.join("lib", "tasks", "task_helper")
|
|
|
|
|
2018-06-05 16:25:00 +02:00
|
|
|
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
|
|
|
|
]
|
|
|
|
|
2018-06-07 16:03:45 +02:00
|
|
|
dossiers = ids.map { |id| Dossier.find_by(id: id) }.compact
|
2018-06-05 16:25:00 +02:00
|
|
|
|
|
|
|
dossiers.each do |dossier|
|
|
|
|
attestation = dossier.attestation
|
2018-06-07 17:25:39 +02:00
|
|
|
|
|
|
|
if attestation
|
|
|
|
id = attestation.id
|
|
|
|
attestation.destroy
|
2018-06-12 18:17:37 +02:00
|
|
|
rake_puts "Attestation #{id} détruite"
|
2018-06-07 17:25:39 +02:00
|
|
|
end
|
2018-06-05 16:25:00 +02:00
|
|
|
|
|
|
|
dossier.attestation = dossier.build_attestation
|
|
|
|
|
2018-06-07 17:23:12 +02:00
|
|
|
NewAttestationMailer.new_attestation(dossier).deliver_later
|
2018-06-12 18:17:37 +02:00
|
|
|
rake_puts "Email envoyé à #{dossier.user.email} pour le dossier #{dossier.id}"
|
|
|
|
rake_puts
|
2018-06-05 16:25:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|