Merge pull request #9348 from tchak/feat-submit-en-construction
refactor: move submit en_construction logic to the model
This commit is contained in:
commit
1dfb3817e6
2 changed files with 18 additions and 6 deletions
|
@ -226,14 +226,10 @@ module Users
|
||||||
errors = submit_dossier_and_compute_errors
|
errors = submit_dossier_and_compute_errors
|
||||||
|
|
||||||
if errors.blank?
|
if errors.blank?
|
||||||
|
pending_correction_confirm = cast_bool(params.dig(:dossier, :pending_correction_confirm))
|
||||||
editing_fork_origin = @dossier.editing_fork_origin
|
editing_fork_origin = @dossier.editing_fork_origin
|
||||||
editing_fork_origin.merge_fork(@dossier)
|
editing_fork_origin.merge_fork(@dossier)
|
||||||
RoutingEngine.compute(editing_fork_origin)
|
editing_fork_origin.submit_en_construction!(pending_correction_confirm:)
|
||||||
|
|
||||||
if cast_bool(params.dig(:dossier, :pending_correction_confirm))
|
|
||||||
editing_fork_origin.resolve_pending_correction!
|
|
||||||
editing_fork_origin.process_sva_svr!
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to dossier_path(editing_fork_origin)
|
redirect_to dossier_path(editing_fork_origin)
|
||||||
else
|
else
|
||||||
|
|
|
@ -120,6 +120,10 @@ class Dossier < ApplicationRecord
|
||||||
processed_at: processed_at)
|
processed_at: processed_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submit_en_construction(processed_at: Time.zone.now)
|
||||||
|
build(state: Dossier.states.fetch(:en_construction), processed_at:)
|
||||||
|
end
|
||||||
|
|
||||||
def passer_en_instruction(instructeur: nil, processed_at: Time.zone.now)
|
def passer_en_instruction(instructeur: nil, processed_at: Time.zone.now)
|
||||||
build(state: Dossier.states.fetch(:en_instruction),
|
build(state: Dossier.states.fetch(:en_instruction),
|
||||||
instructeur_email: instructeur&.email,
|
instructeur_email: instructeur&.email,
|
||||||
|
@ -908,6 +912,18 @@ class Dossier < ApplicationRecord
|
||||||
RoutingEngine.compute(self)
|
RoutingEngine.compute(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submit_en_construction!(pending_correction_confirm: false)
|
||||||
|
self.traitements.submit_en_construction
|
||||||
|
save!
|
||||||
|
|
||||||
|
RoutingEngine.compute(self)
|
||||||
|
|
||||||
|
if pending_correction_confirm
|
||||||
|
resolve_pending_correction!
|
||||||
|
process_sva_svr!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def after_passer_en_instruction(h)
|
def after_passer_en_instruction(h)
|
||||||
instructeur = h[:instructeur]
|
instructeur = h[:instructeur]
|
||||||
disable_notification = h.fetch(:disable_notification, false)
|
disable_notification = h.fetch(:disable_notification, false)
|
||||||
|
|
Loading…
Reference in a new issue