diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 31032bcb5..0b05d2824 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -136,9 +136,7 @@ class Admin::ProceduresController < AdminController render '/admin/procedures/transfer', formats: 'js', status: 404 else procedure = current_administrateur.procedures.find(params[:procedure_id]) - clone_procedure = procedure.clone(admin, false) - - clone_procedure.save + procedure.clone(admin, false) flash.now.notice = "La démarche a correctement été clonée vers le nouvel administrateur." @@ -162,7 +160,7 @@ class Admin::ProceduresController < AdminController procedure = Procedure.find(params[:procedure_id]) new_procedure = procedure.clone(current_administrateur, cloned_from_library?) - if new_procedure.save + if new_procedure.valid? flash.notice = 'Démarche clonée' redirect_to edit_admin_procedure_path(id: new_procedure.id) else diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 9ea61980b..a340bf53a 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -247,6 +247,8 @@ class Procedure < ApplicationRecord procedure.service = self.service.clone_and_assign_to_administrateur(admin) end + procedure.save + admin.instructeur.assign_to_procedure(procedure) procedure