diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 27ceb25c5..3a339bf71 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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