Add Procedure#publish_with_path!

This commit is contained in:
Paul Chavard 2018-09-07 17:40:36 +01:00
parent e6485603c4
commit b3f8b68b99

View file

@ -84,6 +84,18 @@ class Procedure < ApplicationRecord
end
end
def publish_with_path!(path)
procedure_path = ProcedurePath
.where(administrateur: administrateur)
.find_by(path: path)
if procedure_path.present?
procedure_path.publish!(self)
else
create_procedure_path!(administrateur: administrateur, path: path)
end
end
def reset!
if locked?
raise "Can not reset a locked procedure."