Set published_at on revision when publishing a procedure

This commit is contained in:
Paul Chavard 2021-04-13 17:41:49 +01:00
parent 306e5d228d
commit 3fb10fb4b8

View file

@ -248,10 +248,10 @@ class Procedure < ApplicationRecord
state :close state :close
state :depubliee state :depubliee
event :publish, before: :before_publish, after: :after_publish do event :publish, before: :before_publish do
transitions from: :brouillon, to: :publiee transitions from: :brouillon, to: :publiee, after: :after_publish
transitions from: :close, to: :publiee transitions from: :close, to: :publiee, after: :after_republish
transitions from: :depubliee, to: :publiee transitions from: :depubliee, to: :publiee, after: :after_republish
end end
event :close, after: :after_close do event :close, after: :after_close do
@ -694,6 +694,11 @@ class Procedure < ApplicationRecord
def after_publish(canonical_procedure = nil) 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) 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 end
def after_close def after_close