Use new primitives in procedures controller
This commit is contained in:
parent
6b683cc491
commit
6345d5d153
1 changed files with 9 additions and 16 deletions
|
@ -109,22 +109,15 @@ class Admin::ProceduresController < AdminController
|
||||||
return redirect_to admin_procedures_path
|
return redirect_to admin_procedures_path
|
||||||
end
|
end
|
||||||
|
|
||||||
procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
|
if procedure.may_publish?(params[:procedure_path])
|
||||||
if procedure_path
|
procedure.publish!(params[:procedure_path])
|
||||||
if procedure_path.administrateur_id == current_administrateur.id
|
|
||||||
procedure_path.procedure.archive
|
flash.notice = "Procédure publiée"
|
||||||
procedure_path.delete
|
redirect_to admin_procedures_path
|
||||||
else
|
else
|
||||||
@mine = false
|
@mine = false
|
||||||
return render '/admin/procedures/publish', formats: 'js'
|
render '/admin/procedures/publish', formats: 'js'
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
procedure.publish!(params[:procedure_path])
|
|
||||||
|
|
||||||
flash.notice = "Procédure publiée"
|
|
||||||
render js: "window.location = '#{admin_procedures_path}'"
|
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = 'Procédure inexistante'
|
flash.alert = 'Procédure inexistante'
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
|
@ -149,7 +142,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def archive
|
def archive
|
||||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||||
procedure.archive
|
procedure.archive!
|
||||||
|
|
||||||
flash.notice = "Procédure archivée"
|
flash.notice = "Procédure archivée"
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
|
|
Loading…
Reference in a new issue