Use Procedure#publish_or_reopen!
This commit is contained in:
parent
ec3a0dc4cf
commit
5a794cbb08
2 changed files with 10 additions and 3 deletions
|
@ -99,9 +99,7 @@ class Admin::ProceduresController < AdminController
|
||||||
return redirect_to admin_procedures_path
|
return redirect_to admin_procedures_path
|
||||||
end
|
end
|
||||||
|
|
||||||
if procedure.may_publish?(params[:procedure_path])
|
if procedure.publish_or_reopen!(params[:procedure_path])
|
||||||
procedure.publish!(params[:procedure_path])
|
|
||||||
|
|
||||||
flash.notice = "Démarche publiée"
|
flash.notice = "Démarche publiée"
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
else
|
else
|
||||||
|
|
|
@ -84,6 +84,15 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def publish_or_reopen!(path)
|
||||||
|
if archivee? && may_reopen?(path)
|
||||||
|
reopen!(path)
|
||||||
|
elsif may_publish?(path)
|
||||||
|
reset!
|
||||||
|
publish!(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def publish_with_path!(path)
|
def publish_with_path!(path)
|
||||||
procedure_path = ProcedurePath
|
procedure_path = ProcedurePath
|
||||||
.where(administrateur: administrateur)
|
.where(administrateur: administrateur)
|
||||||
|
|
Loading…
Reference in a new issue