Set published_at on revision when publishing a procedure
This commit is contained in:
parent
306e5d228d
commit
3fb10fb4b8
1 changed files with 9 additions and 4 deletions
|
@ -248,10 +248,10 @@ class Procedure < ApplicationRecord
|
|||
state :close
|
||||
state :depubliee
|
||||
|
||||
event :publish, before: :before_publish, after: :after_publish do
|
||||
transitions from: :brouillon, to: :publiee
|
||||
transitions from: :close, to: :publiee
|
||||
transitions from: :depubliee, to: :publiee
|
||||
event :publish, before: :before_publish do
|
||||
transitions from: :brouillon, to: :publiee, after: :after_publish
|
||||
transitions from: :close, to: :publiee, after: :after_republish
|
||||
transitions from: :depubliee, to: :publiee, after: :after_republish
|
||||
end
|
||||
|
||||
event :close, after: :after_close do
|
||||
|
@ -694,6 +694,11 @@ class Procedure < ApplicationRecord
|
|||
|
||||
def after_publish(canonical_procedure = nil)
|
||||
update!(published_at: Time.zone.now, canonical_procedure: canonical_procedure, draft_revision: create_new_revision, published_revision: draft_revision)
|
||||
published_revision.update!(published_at: Time.zone.now)
|
||||
end
|
||||
|
||||
def after_republish(canonical_procedure = nil)
|
||||
update!(published_at: Time.zone.now)
|
||||
end
|
||||
|
||||
def after_close
|
||||
|
|
Loading…
Reference in a new issue