[#10951] Create a cron job to warn user that old brouillon is deleted

This commit is contained in:
Mathieu Magnin 2024-11-19 16:55:23 +01:00
parent 38e9ca4979
commit 5ab0899a49
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
6 changed files with 84 additions and 1 deletions

View 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

View file

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

View file

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