Class: Message
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Message
- 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", "non-checked-in-excluding" => "Non-Checked-In Applications, Excluding Accepted & RSVP'd", "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
- #can_edit? ⇒ Boolean
- #delivered? ⇒ Boolean
- #queued? ⇒ Boolean
- #recipients=(values) ⇒ Object
- #recipients_list ⇒ Object
- #started? ⇒ Boolean
- #status ⇒ Object
- #using_default_template? ⇒ Boolean
Instance Method Details
#can_edit? ⇒ Boolean
70 71 72 |
# File 'app/models/message.rb', line 70 def can_edit? status == "drafted" end |
#delivered? ⇒ Boolean
51 52 53 |
# File 'app/models/message.rb', line 51 def delivered? delivered_at.present? end |
#queued? ⇒ Boolean
59 60 61 |
# File 'app/models/message.rb', line 59 def queued? queued_at.present? end |
#recipients=(values) ⇒ Object
43 44 45 |
# File 'app/models/message.rb', line 43 def recipients=(values) values.present? ? super(values.reject(&:blank?)) : super(values) end |
#recipients_list ⇒ Object
47 48 49 |
# File 'app/models/message.rb', line 47 def recipients_list recipients.map { |r| POSSIBLE_RECIPIENTS[r] }.join(', ') end |
#started? ⇒ Boolean
55 56 57 |
# File 'app/models/message.rb', line 55 def started? started_at.present? end |
#status ⇒ Object
63 64 65 66 67 68 |
# File 'app/models/message.rb', line 63 def status return "delivered" if delivered? return "started" if started? return "queued" if queued? "drafted" end |
#using_default_template? ⇒ Boolean
74 75 76 |
# File 'app/models/message.rb', line 74 def using_default_template? template == "default" end |