[#10951] Create a cron job to warn user that old brouillon is deleted
This commit is contained in:
parent
38e9ca4979
commit
5ab0899a49
6 changed files with 84 additions and 1 deletions
15
app/jobs/cron/purge_old_brouillon_dossiers_job.rb
Normal file
15
app/jobs/cron/purge_old_brouillon_dossiers_job.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Cron::PurgeOldBrouillonDossiersJob < Cron::CronJob
|
||||
self.schedule_expression = "every day at 08:30"
|
||||
|
||||
def perform
|
||||
Dossier
|
||||
.state_brouillon
|
||||
.where(updated_at: ..(3.months + 2.weeks).ago)
|
||||
.find_each do |dossier|
|
||||
dossier.hide_and_keep_track!(:automatic, :not_modified_for_a_long_time)
|
||||
DossierMailer.notify_old_brouillon_after_deletion(dossier).deliver_later
|
||||
end
|
||||
end
|
||||
end
|
|
@ -567,7 +567,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_be_deleted_by_automatic?(reason)
|
||||
reason == :expired && !en_instruction?
|
||||
reason == :expired && !en_instruction? || reason == :not_modified_for_a_long_time && brouillon?
|
||||
end
|
||||
|
||||
def can_terminer_automatiquement_by_sva_svr?
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
- content_for(:title, "#{@subject}")
|
||||
|
||||
%p= t(:hello, scope: [:views, :shared, :greetings])
|
||||
|
||||
%p= t('.body', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle)
|
||||
|
||||
%p= t('.new_dossier_html', link: commencer_url(@dossier.procedure))
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
Loading…
Add table
Add a link
Reference in a new issue