Add reopen aasm event
This commit is contained in:
parent
5a794cbb08
commit
be51802983
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue