Sha256: 5ac32474cb55e07d9461b9052894be861e04fa59587fd313e01310f77fc3105b

Contents?: true

Size: 1.84 KB

Versions: 63

Compression:

Stored size: 1.84 KB

Contents

require "safe_html"

class Action
  include Mongoid::Document

  STATUS_ACTIONS = [
    CREATE                      = "create",
    REQUEST_REVIEW              = "request_review",
    APPROVE_REVIEW              = "approve_review",
    APPROVE_FACT_CHECK          = "approve_fact_check",
    REQUEST_AMENDMENTS          = "request_amendments",
    SEND_FACT_CHECK             = "send_fact_check",
    RECEIVE_FACT_CHECK          = "receive_fact_check",
    SKIP_FACT_CHECK             = "skip_fact_check",
    SCHEDULE_FOR_PUBLISHING     = "schedule_for_publishing",
    CANCEL_SCHEDULED_PUBLISHING = "cancel_scheduled_publishing",
    PUBLISH                     = "publish",
    ARCHIVE                     = "archive",
    NEW_VERSION                 = "new_version",
  ]

  NON_STATUS_ACTIONS = [
    NOTE                 = "note",
    ASSIGN               = "assign",
  ]

  embedded_in :edition

  belongs_to :recipient, class_name: "User"
  belongs_to :requester, class_name: "User"

  field :approver_id,        type: Integer
  field :approved,           type: DateTime
  field :comment,            type: String
  field :comment_sanitized,  type: Boolean, default: false
  field :diff,               type: String
  field :request_type,       type: String
  field :email_addresses,    type: String
  field :customised_message, type: String
  field :created_at,         type: DateTime, default: lambda { Time.zone.now }

  GOVSPEAK_FIELDS = []
  validates_with SafeHtml

  def container_class_name(edition)
    edition.container.class.name.underscore.humanize
  end

  def status_action?
    STATUS_ACTIONS.include?(request_type)
  end

  def to_s
    request_type.humanize.capitalize
  end

  def is_fact_check_request?
    # SEND_FACT_CHECK is now a state - in older publications it isn't
    request_type == SEND_FACT_CHECK || request_type == "fact_check_requested"
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
govuk_content_models-20.2.0 app/models/action.rb
govuk_content_models-20.1.0 app/models/action.rb
govuk_content_models-20.0.0 app/models/action.rb
govuk_content_models-19.0.0 app/models/action.rb
govuk_content_models-18.0.0 app/models/action.rb
govuk_content_models-17.2.1 app/models/action.rb
govuk_content_models-17.1.1 app/models/action.rb
govuk_content_models-17.1.0 app/models/action.rb
govuk_content_models-17.0.0 app/models/action.rb
govuk_content_models-16.2.0 app/models/action.rb
govuk_content_models-16.1.1 app/models/action.rb
govuk_content_models-16.1.0 app/models/action.rb
govuk_content_models-16.0.0 app/models/action.rb
govuk_content_models-15.1.2 app/models/action.rb
govuk_content_models-15.1.1 app/models/action.rb
govuk_content_models-15.1.0 app/models/action.rb
govuk_content_models-15.0.0 app/models/action.rb
govuk_content_models-14.1.1 app/models/action.rb
govuk_content_models-14.1.0 app/models/action.rb
govuk_content_models-14.0.1 app/models/action.rb