app/models/workflow.rb in govuk_content_models-7.3.1 vs app/models/workflow.rb in govuk_content_models-8.0.0
- old
+ new
@@ -11,27 +11,23 @@
before_destroy :check_can_delete_and_notify
before_save :denormalise_users
after_create :notify_siblings_of_new_edition
- field :state, type: String, default: "lined_up"
+ field :state, type: String, default: "draft"
belongs_to :assigned_to, class_name: "User"
embeds_many :actions
- state_machine initial: :lined_up do
+ state_machine initial: :draft do
after_transition on: :request_amendments do |edition, transition|
edition.mark_as_rejected
end
after_transition on: :publish do |edition, transition|
edition.was_published
end
- event :start_work do
- transition lined_up: :draft
- end
-
event :request_review do
transition [:draft, :amends_needed] => :in_review
end
event :approve_review do
@@ -41,16 +37,16 @@
event :approve_fact_check do
transition fact_check_received: :ready
end
event :request_amendments do
- transition [:fact_check_received, :in_review] => :amends_needed
+ transition [:fact_check_received, :in_review, :ready, :fact_check] => :amends_needed
end
# Editions can optionally be sent out for fact check
event :send_fact_check do
- transition ready: :fact_check
+ transition [:ready, :fact_check_received] => :fact_check
end
# If no response is received to a fact check request we can skip
# that fact check and return the edition to the 'ready' state
event :skip_fact_check do
@@ -74,13 +70,9 @@
event :archive do
transition all => :archived, :unless => :archived?
end
end
-
- # alias_method :created_by, :creator
- # alias_method :published_by, :publisher
- # alias_method :archived_by, :archiver
end
def fact_checked?
(self.actions.where(request_type: Action::APPROVE_FACT_CHECK).count > 0)
end