Procedure: save procedure while cloning

This is required to be able to assign the administrateur.instructeur to the defaut_groupe_instructeur of the new procedure
This commit is contained in:
simon lehericey 2019-08-21 16:33:26 +02:00
parent a2061fba79
commit a82d49aa60
2 changed files with 4 additions and 4 deletions

View file

@ -136,9 +136,7 @@ class Admin::ProceduresController < AdminController
render '/admin/procedures/transfer', formats: 'js', status: 404 render '/admin/procedures/transfer', formats: 'js', status: 404
else else
procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure = current_administrateur.procedures.find(params[:procedure_id])
clone_procedure = procedure.clone(admin, false) procedure.clone(admin, false)
clone_procedure.save
flash.now.notice = "La démarche a correctement été clonée vers le nouvel administrateur." 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]) procedure = Procedure.find(params[:procedure_id])
new_procedure = procedure.clone(current_administrateur, cloned_from_library?) new_procedure = procedure.clone(current_administrateur, cloned_from_library?)
if new_procedure.save if new_procedure.valid?
flash.notice = 'Démarche clonée' flash.notice = 'Démarche clonée'
redirect_to edit_admin_procedure_path(id: new_procedure.id) redirect_to edit_admin_procedure_path(id: new_procedure.id)
else else

View file

@ -247,6 +247,8 @@ class Procedure < ApplicationRecord
procedure.service = self.service.clone_and_assign_to_administrateur(admin) procedure.service = self.service.clone_and_assign_to_administrateur(admin)
end end
procedure.save
admin.instructeur.assign_to_procedure(procedure) admin.instructeur.assign_to_procedure(procedure)
procedure procedure