Class: Message

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/message.rb

Constant Summary collapse

POSSIBLE_TEMPLATES =
["default"].freeze
POSSIBLE_RECIPIENTS =
{
  "all"                              => "Everyone",
  "incomplete"                       => "Incomplete Applications",
  "complete"                         => "Complete Applications",
  "accepted"                         => "Accepted Applications",
  "denied"                           => "Denied Applications",
  "waitlisted"                       => "Waitlisted Applications",
  "late-waitlisted"                  => "Late, Waitlisted Applications",
  "rsvp-confirmed"                   => "RSVP Confirmed Attendees",
  "rsvp-denied"                      => "RSVP Denied Attendees",
  "checked-in"                       => "Checked-In Attendees",
  "non-checked-in"                   => "Non-Checked-In, Accepted & RSVP'd Applications",
  "bus-list-cornell-bing"            => "Bus List: Cornell + Binghamton (Confirmed)",
  "bus-list-buffalo"                 => "Bus List: Buffalo (Confirmed)",
  "bus-list-albany"                  => "Bus List: Albany (Confirmed)",
  "bus-list-cornell-bing-eligible"   => "Bus List: Cornell + Binghamton (eligible, not signed up)",
  "bus-list-buffalo-eligible"        => "Bus List: Buffalo (eligible, not signed up)",
  "bus-list-albany-eligible"         => "Bus List: Albany (eligible, not signed up)",
  "bus-list-cornell-bing-applied"    => "Bus List: Cornell + Binghamton (applied/not accepted)",
  "bus-list-buffalo-applied"         => "Bus List: Buffalo (applied/not accepted)",
  "bus-list-albany-applied"          => "Bus List: Albany (applied/not accepted)",
  "school-rit"                       => "Confirmed or accepted: RIT",
  "school-cornell"                   => "Confirmed or accepted: Cornell",
  "school-binghamton"                => "Confirmed or accepted: Binghamton",
  "school-buffalo"                   => "Confirmed or accepted: Buffalo",
  "school-waterloo"                  => "Confirmed or accepted: Waterloo",
  "school-toronto"                   => "Confirmed or accepted: Toronto",
  "school-umd-collegepark"           => "Confirmed or accepted: UMD College Park"
}.freeze

Instance Method Summary collapse

Instance Method Details

#can_edit?Boolean



69
70
71
# File 'app/models/message.rb', line 69

def can_edit?
  status == "drafted"
end

#delivered?Boolean



50
51
52
# File 'app/models/message.rb', line 50

def delivered?
  delivered_at.present?
end

#queued?Boolean



58
59
60
# File 'app/models/message.rb', line 58

def queued?
  queued_at.present?
end

#recipients=(values) ⇒ Object



42
43
44
# File 'app/models/message.rb', line 42

def recipients=(values)
  values.present? ? super(values.reject(&:blank?)) : super(values)
end

#recipients_listObject



46
47
48
# File 'app/models/message.rb', line 46

def recipients_list
  recipients.map { |r| POSSIBLE_RECIPIENTS[r] }.join(', ')
end

#started?Boolean



54
55
56
# File 'app/models/message.rb', line 54

def started?
  started_at.present?
end

#statusObject



62
63
64
65
66
67
# File 'app/models/message.rb', line 62

def status
  return "delivered" if delivered?
  return "started" if started?
  return "queued" if queued?
  "drafted"
end

#using_default_template?Boolean



73
74
75
# File 'app/models/message.rb', line 73

def using_default_template?
  template == "default"
end