Use Procedure#publish_or_reopen!

This commit is contained in:
Paul Chavard 2018-09-07 17:42:12 +01:00
parent ec3a0dc4cf
commit 5a794cbb08
2 changed files with 10 additions and 3 deletions

View file

@ -99,9 +99,7 @@ class Admin::ProceduresController < AdminController
return redirect_to admin_procedures_path
end
if procedure.may_publish?(params[:procedure_path])
procedure.publish!(params[:procedure_path])
if procedure.publish_or_reopen!(params[:procedure_path])
flash.notice = "Démarche publiée"
redirect_to admin_procedures_path
else

View file

@ -84,6 +84,15 @@ class Procedure < ApplicationRecord
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)
procedure_path = ProcedurePath
.where(administrateur: administrateur)