Add reopen aasm event

This commit is contained in:
Paul Chavard 2018-09-07 17:37:44 +01:00
parent 5a794cbb08
commit be51802983

View file

@ -70,6 +70,9 @@ class Procedure < ApplicationRecord
event :publish, after: :after_publish, guard: :can_publish? do
transitions from: :brouillon, to: :publiee
end
event :reopen, after: :after_reopen, guard: :can_publish? do
transitions from: :archivee, to: :publiee
end
@ -383,6 +386,12 @@ class Procedure < ApplicationRecord
dossiers.update_all(hidden_at: now)
end
def after_reopen(path)
update!(published_at: Time.now, archived_at: nil)
publish_with_path!(path)
end
def update_juridique_required
self.juridique_required ||= (cadre_juridique.present? || deliberation.attached?)
true