Skip to content

Commit

Permalink
refactor: move submit en_construction logic to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed Jul 24, 2023
1 parent c4dfd45 commit 717acf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,10 @@ def submit_en_construction
errors = submit_dossier_and_compute_errors

if errors.blank?
pending_correction_confirm = cast_bool(params.dig(:dossier, :pending_correction_confirm))
editing_fork_origin = @dossier.editing_fork_origin
editing_fork_origin.merge_fork(@dossier)
RoutingEngine.compute(editing_fork_origin)

if cast_bool(params.dig(:dossier, :pending_correction_confirm))
editing_fork_origin.resolve_pending_correction!
editing_fork_origin.process_sva_svr!
end
editing_fork_origin.submit_en_construction!(pending_correction_confirm:)

redirect_to dossier_path(editing_fork_origin)
else
Expand Down
13 changes: 13 additions & 0 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,19 @@ def after_passer_en_construction
RoutingEngine.compute(self)
end

def submit_en_construction!(pending_correction_confirm: false)
self.conservation_extension = 0.days
self.traitements.passer_en_construction.processed_at
save!

RoutingEngine.compute(self)

if pending_correction_confirm
resolve_pending_correction!
process_sva_svr!
end
end

def after_passer_en_instruction(h)
instructeur = h[:instructeur]
disable_notification = h.fetch(:disable_notification, false)
Expand Down

0 comments on commit 717acf5

Please sign in to comment.