refactor(dossier): move some code to dossier_state_concern
This commit is contained in:
parent
6914d78236
commit
671d121480
3 changed files with 21 additions and 16 deletions
|
@ -233,11 +233,6 @@ module Users
|
|||
|
||||
if @dossier.errors.blank? && @dossier.can_passer_en_construction?
|
||||
@dossier.passer_en_construction!
|
||||
@dossier.process_declarative!
|
||||
@dossier.process_sva_svr!
|
||||
@dossier.groupe_instructeur.instructeurs.with_instant_email_dossier_notifications.each do |instructeur|
|
||||
DossierMailer.notify_new_dossier_depose_to_instructeur(@dossier, instructeur.email).deliver_later
|
||||
end
|
||||
redirect_to merci_dossier_path(@dossier)
|
||||
else
|
||||
respond_to do |format|
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
module DossierStateConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def submit_en_construction!
|
||||
self.traitements.submit_en_construction
|
||||
save!
|
||||
|
||||
RoutingEngine.compute(self)
|
||||
|
||||
resolve_pending_correction!
|
||||
process_sva_svr!
|
||||
remove_piece_justificative_file_not_visible!
|
||||
|
||||
editing_forks.each(&:destroy_editing_fork!)
|
||||
end
|
||||
|
||||
def after_passer_en_construction
|
||||
self.conservation_extension = 0.days
|
||||
self.depose_at = self.en_construction_at = self.traitements
|
||||
|
@ -16,12 +29,18 @@ module DossierStateConcern
|
|||
MailTemplatePresenterService.create_commentaire_for_state(self, Dossier.states.fetch(:en_construction))
|
||||
procedure.compute_dossiers_count
|
||||
|
||||
process_declarative!
|
||||
process_sva_svr!
|
||||
|
||||
index_search_terms_later
|
||||
end
|
||||
|
||||
def after_commit_passer_en_construction
|
||||
NotificationMailer.send_en_construction_notification(self).deliver_later
|
||||
NotificationMailer.send_notification_for_tiers(self).deliver_later if self.for_tiers?
|
||||
groupe_instructeur.instructeurs.with_instant_email_dossier_notifications.each do |instructeur|
|
||||
DossierMailer.notify_new_dossier_depose_to_instructeur(self, instructeur.email).deliver_later
|
||||
end
|
||||
remove_piece_justificative_file_not_visible!
|
||||
end
|
||||
|
||||
|
@ -49,6 +68,8 @@ module DossierStateConcern
|
|||
NotificationMailer.send_en_instruction_notification(self).deliver_later
|
||||
NotificationMailer.send_notification_for_tiers(self).deliver_later if self.for_tiers?
|
||||
end
|
||||
|
||||
editing_forks.each(&:destroy_editing_fork!)
|
||||
end
|
||||
|
||||
def after_passer_automatiquement_en_instruction
|
||||
|
|
|
@ -865,17 +865,6 @@ class Dossier < ApplicationRecord
|
|||
procedure.email_template_for(state)
|
||||
end
|
||||
|
||||
def submit_en_construction!
|
||||
self.traitements.submit_en_construction
|
||||
save!
|
||||
|
||||
RoutingEngine.compute(self)
|
||||
|
||||
resolve_pending_correction!
|
||||
process_sva_svr!
|
||||
remove_piece_justificative_file_not_visible!
|
||||
end
|
||||
|
||||
def process_declarative!
|
||||
if procedure.declarative_accepte? && may_accepter_automatiquement?
|
||||
accepter_automatiquement!
|
||||
|
|
Loading…
Reference in a new issue