Task to unhide dossiers with instruction commencee
This commit is contained in:
parent
89f82ba92e
commit
ae6e3e345e
4 changed files with 32 additions and 0 deletions
|
@ -14,4 +14,11 @@ class DossierMailer < ApplicationMailer
|
||||||
|
|
||||||
mail(to: to_email, subject: subject)
|
mail(to: to_email, subject: subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_unhide_to_user(dossier)
|
||||||
|
@dossier = dossier
|
||||||
|
subject = "Votre dossier n° #{@dossier.id} n'a pas pu être supprimé"
|
||||||
|
|
||||||
|
mail(to: dossier.user.email, subject: subject)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,7 @@ class Dossier < ApplicationRecord
|
||||||
scope :state_en_construction, -> { where(state: 'en_construction') }
|
scope :state_en_construction, -> { where(state: 'en_construction') }
|
||||||
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
||||||
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
||||||
|
scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) }
|
||||||
scope :state_termine, -> { where(state: TERMINE) }
|
scope :state_termine, -> { where(state: TERMINE) }
|
||||||
|
|
||||||
scope :archived, -> { where(archived: true) }
|
scope :archived, -> { where(archived: true) }
|
||||||
|
|
13
app/views/dossier_mailer/notify_unhide_to_user.html.haml
Normal file
13
app/views/dossier_mailer/notify_unhide_to_user.html.haml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
- content_for(:title, "Votre dossier n° #{@dossier.id} n'a pas pu être supprimé")
|
||||||
|
|
||||||
|
%h1 Bonjour,
|
||||||
|
|
||||||
|
%p
|
||||||
|
L'instruction de votre dossier n° #{@dossier.id} ayant commencé, il n'a pas pu être supprimé.
|
||||||
|
Le dossier a été rétabli dans votre tableau de bord.
|
||||||
|
|
||||||
|
%p
|
||||||
|
Bonne journée,
|
||||||
|
|
||||||
|
%p
|
||||||
|
L'équipe demarches-simplifiees.fr
|
11
lib/tasks/2018_06_13_unhide_dossiers.rake
Normal file
11
lib/tasks/2018_06_13_unhide_dossiers.rake
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
namespace :'2018_06_13_unhide_dossiers' do
|
||||||
|
task run: :environment do
|
||||||
|
Dossier.unscoped.where.not(hidden_at: nil).state_instruction_commencee.each do |d|
|
||||||
|
if !d.procedure.nil? # ensure the procedure was not deleted by administrateur for testing
|
||||||
|
d.update(hidden_at: nil)
|
||||||
|
DeletedDossier.find_by(dossier_id: d.id)&.destroy
|
||||||
|
DossierMailer.notify_unhide_to_user(d).deliver_later
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue