Merge pull request #10855 from mfo/US/fix-resolve
ETQ administrateur je ne souhatie pas que mes usagers aient une demande de correction suite à un depot de dossier trop ancien
This commit is contained in:
commit
5b268fff29
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
# this maintenance task should be run due to app/tasks/maintenance/fix_champs_commune_having_value_but_not_external_id_task.rb
|
||||
# if you have not ran app/tasks/maintenance/fix_champs_commune_having_value_but_not_external_id_task.rb, this task is not required
|
||||
class ResolvePendingCorrectionForDossierWithInvalidCommuneExternalIdTask < MaintenanceTasks::Task
|
||||
DEFAULT_INSTRUCTEUR_EMAIL = ENV.fetch('DEFAULT_INSTRUCTEUR_EMAIL') { CONTACT_EMAIL }
|
||||
|
||||
|
@ -14,6 +16,8 @@ module Maintenance
|
|||
penultimate_traitement, last_traitement = *dossier_correction.dossier.traitements.last(2)
|
||||
dossier_correction.resolve!
|
||||
|
||||
next if penultimate_traitement.nil? || last_traitement.nil?
|
||||
|
||||
if last_traitement_by_us?(last_traitement) && last_transition_to_en_construction?(last_traitement, penultimate_traitement)
|
||||
dossier_correction.dossier.passer_en_instruction(instructeur: current_instructeur) if dossier_correction.dossier.validate(:champs_public_value)
|
||||
end
|
||||
|
@ -33,7 +37,7 @@ module Maintenance
|
|||
end
|
||||
|
||||
def last_traitement_by_us?(traitement)
|
||||
traitement.instructeur_email == DEFAULT_INSTRUCTEUR_EMAIL
|
||||
traitement&.instructeur_email == DEFAULT_INSTRUCTEUR_EMAIL
|
||||
end
|
||||
|
||||
def last_transition_to_en_construction?(last_traitement, penultimate_traitement)
|
||||
|
|
Loading…
Reference in a new issue