amelioration(dossier.routage): assigne le groupe d'instructeur au moment de passer_en_construction! un dossier et ignore ce concept de pre-setter le groupe d'instructeur sur tout le reste de l'app
This commit is contained in:
parent
1e820b124e
commit
05687e63ca
9 changed files with 71 additions and 34 deletions
|
@ -4,7 +4,6 @@ class API::Public::V1::DossiersController < API::Public::V1::BaseController
|
|||
def create
|
||||
dossier = Dossier.new(
|
||||
revision: @procedure.active_revision,
|
||||
groupe_instructeur: @procedure.defaut_groupe_instructeur_for_new_dossier,
|
||||
state: Dossier.states.fetch(:brouillon),
|
||||
prefilled: true
|
||||
)
|
||||
|
|
|
@ -96,7 +96,6 @@ module Users
|
|||
def build_prefilled_dossier
|
||||
@prefilled_dossier = Dossier.new(
|
||||
revision: @revision,
|
||||
groupe_instructeur: @procedure.defaut_groupe_instructeur_for_new_dossier,
|
||||
state: Dossier.states.fetch(:brouillon),
|
||||
prefilled: true
|
||||
)
|
||||
|
|
|
@ -375,7 +375,6 @@ module Users
|
|||
|
||||
dossier = Dossier.new(
|
||||
revision: params[:brouillon] ? procedure.draft_revision : procedure.active_revision,
|
||||
groupe_instructeur: procedure.defaut_groupe_instructeur_for_new_dossier,
|
||||
user: current_user,
|
||||
state: Dossier.states.fetch(:brouillon)
|
||||
)
|
||||
|
@ -559,7 +558,6 @@ module Users
|
|||
@dossier.valid?(**submit_validation_options)
|
||||
errors += format_errors(errors: @dossier.errors)
|
||||
errors += format_errors(errors: @dossier.check_mandatory_and_visible_champs)
|
||||
|
||||
errors
|
||||
end
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@ module DossierCloneConcern
|
|||
end
|
||||
|
||||
def clone(user: nil, fork: false)
|
||||
dossier_attributes = [:autorisation_donnees, :revision_id, :groupe_instructeur_id]
|
||||
dossier_attributes = [:autorisation_donnees, :revision_id]
|
||||
dossier_attributes += [:groupe_instructeur_id] if fork
|
||||
relationships = [:individual, :etablissement]
|
||||
|
||||
cloned_champs = champs
|
||||
|
@ -95,7 +96,6 @@ module DossierCloneConcern
|
|||
|
||||
kopy.user = user || original.user
|
||||
kopy.state = Dossier.states.fetch(:brouillon)
|
||||
|
||||
kopy.champs = cloned_champs.values.map do |(_, champ)|
|
||||
champ.dossier = kopy
|
||||
champ.parent = cloned_champs[champ.parent_id].second if champ.child?
|
||||
|
|
|
@ -135,7 +135,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
aasm whiny_persistence: true, column: :state, enum: true do
|
||||
state :brouillon, initial: true
|
||||
state :en_construction
|
||||
state :en_construction, before_enter: :compute_routing
|
||||
state :en_instruction
|
||||
state :accepte
|
||||
state :refuse
|
||||
|
@ -852,7 +852,6 @@ class Dossier < ApplicationRecord
|
|||
.passer_en_construction
|
||||
.processed_at
|
||||
save!
|
||||
|
||||
MailTemplatePresenterService.create_commentaire_for_state(self)
|
||||
NotificationMailer.send_en_construction_notification(self).deliver_later
|
||||
procedure.compute_dossiers_count
|
||||
|
@ -871,6 +870,10 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def compute_routing
|
||||
RoutingEngine.compute(self)
|
||||
end
|
||||
|
||||
def after_passer_en_instruction(h)
|
||||
instructeur = h[:instructeur]
|
||||
disable_notification = h.fetch(:disable_notification, false)
|
||||
|
|
|
@ -666,12 +666,6 @@ class Procedure < ApplicationRecord
|
|||
routing_enabled? || instructeurs_self_management_enabled?
|
||||
end
|
||||
|
||||
def defaut_groupe_instructeur_for_new_dossier
|
||||
if !routing_enabled? || feature_enabled?(:procedure_routage_api)
|
||||
defaut_groupe_instructeur
|
||||
end
|
||||
end
|
||||
|
||||
def groupe_instructeurs_but_defaut
|
||||
groupe_instructeurs - [defaut_groupe_instructeur]
|
||||
end
|
||||
|
|
|
@ -150,7 +150,7 @@ class ProcedureRevision < ApplicationRecord
|
|||
|
||||
def dossier_for_preview(user)
|
||||
dossier = Dossier
|
||||
.create_with(groupe_instructeur: procedure.defaut_groupe_instructeur_for_new_dossier, autorisation_donnees: true)
|
||||
.create_with(autorisation_donnees: true)
|
||||
.find_or_initialize_by(revision: self, user: user, for_procedure_preview: true, state: Dossier.states.fetch(:brouillon))
|
||||
|
||||
if dossier.new_record?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue