Class: Action

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/action.rb

Constant Summary collapse

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",
  IMPORTANT_NOTE       = "important_note",
  IMPORTANT_NOTE_RESOLVED = "important_note_resolved",
  ASSIGN               = "assign",
]
GOVSPEAK_FIELDS =
[]

Instance Method Summary collapse

Instance Method Details

#container_class_name(edition) ⇒ Object



47
48
49
# File 'app/models/action.rb', line 47

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

#is_fact_check_request?Boolean

Returns:

  • (Boolean)


65
66
67
68
# File 'app/models/action.rb', line 65

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

#status_action?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/action.rb', line 51

def status_action?
  STATUS_ACTIONS.include?(request_type)
end

#to_sObject



55
56
57
58
59
60
61
62
63
# File 'app/models/action.rb', line 55

def to_s
  if request_type == SCHEDULE_FOR_PUBLISHING
    string = "Scheduled for publishing"
    string += " on #{request_details['scheduled_time'].strftime('%d/%m/%Y %H:%M %Z')}" if request_details['scheduled_time'].present?
    string
  else
    request_type.humanize.capitalize
  end
end