Class: Questionnaire
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Questionnaire
- Includes:
- ActiveModel::Dirty, DeletableAttachment
- Defined in:
- app/models/questionnaire.rb
Constant Summary collapse
- POSSIBLE_EXPERIENCES =
{ "first" => "This is my 1st hackathon!", "experienced" => "My feet are wet. (1-5 hackathons)", "expert" => "I'm a veteran hacker. (6+ hackathons)" }.freeze
- POSSIBLE_INTERESTS =
{ "design" => "Design", "software" => "Software", "hardware" => "Hardware", "combination" => "Combination of everything!" }.freeze
- POSSIBLE_SHIRT_SIZES =
[ "Women's - XS", "Women's - S", "Women's - M", "Women's - L", "Women's - XL", "Unisex - XS", "Unisex - S", "Unisex - M", "Unisex - L", "Unisex - XL" ].freeze
- POSSIBLE_ACC_STATUS =
{ "pending" => "Pending Review", "accepted" => "Accepted", "waitlist" => "Waitlisted", "denied" => "Denied", "late_waitlist" => "Waitlisted, Late", "rsvp_confirmed" => "RSVP Confirmed", "rsvp_denied" => "RSVP Denied" }.freeze
- POSSIBLE_GENDERS =
From My MLH's dropdown list. Should not validate against this list in case My MLH changes their options, as this would cause errors until a manual gem update
[ "Female", "Male", "Non-Binary", "I prefer not to say", "Other" ].freeze
- POSSIBLE_LEVELS_OF_STUDY =
From My MLH's dropdown list. Should not validate against this list in case My MLH changes their options, as this would cause errors until a manual gem update
[ "Elementary / Middle School / Primary School", "High School / Secondary School", "University (Undergraduate)", "University (Master's / Doctoral)", "Vocational / Code School", "Not Currently a Student", "Other" ].freeze
Instance Method Summary collapse
- #acc_status_author ⇒ Object
- #age_at_time_of_event ⇒ Object
- #boarded_bus? ⇒ Boolean
- #bus_list ⇒ Object
- #can_rsvp? ⇒ Boolean
- #checked_in? ⇒ Boolean
- #checked_in_by ⇒ Object
- #date_of_birth_formatted ⇒ Object
- #did_rsvp? ⇒ Boolean
- #eligible_for_a_bus? ⇒ Boolean
- #email ⇒ Object
- #fips_code ⇒ Object
- #full_location ⇒ Object
- #full_name ⇒ Object
- #invite_to_slack ⇒ Object
- #message_events ⇒ Object
- #minor? ⇒ Boolean
- #portfolio_url=(value) ⇒ Object
- #school ⇒ Object
- #school_name ⇒ Object
- #vcs_url=(value) ⇒ Object
- #verbal_status ⇒ Object
Instance Method Details
#acc_status_author ⇒ Object
136 137 138 139 |
# File 'app/models/questionnaire.rb', line 136 def return unless .present? User.find() end |
#age_at_time_of_event ⇒ Object
158 159 160 |
# File 'app/models/questionnaire.rb', line 158 def age_at_time_of_event (Rails.configuration.hackathon['event_start_date'] - date_of_birth).to_i * 1.day end |
#boarded_bus? ⇒ Boolean
145 146 147 |
# File 'app/models/questionnaire.rb', line 145 def boarded_bus? boarded_bus_at.present? end |
#bus_list ⇒ Object
178 179 180 181 |
# File 'app/models/questionnaire.rb', line 178 def bus_list return unless eligible_for_a_bus? school.bus_list end |
#can_rsvp? ⇒ Boolean
166 167 168 |
# File 'app/models/questionnaire.rb', line 166 def can_rsvp? ["accepted", "rsvp_confirmed", "rsvp_denied"].include? acc_status end |
#checked_in? ⇒ Boolean
141 142 143 |
# File 'app/models/questionnaire.rb', line 141 def checked_in? checked_in_at.present? end |
#checked_in_by ⇒ Object
149 150 151 152 |
# File 'app/models/questionnaire.rb', line 149 def checked_in_by return unless checked_in_by_id.present? User.find(checked_in_by_id) end |
#date_of_birth_formatted ⇒ Object
132 133 134 |
# File 'app/models/questionnaire.rb', line 132 def date_of_birth_formatted date_of_birth.strftime("%B %-d, %Y") end |
#did_rsvp? ⇒ Boolean
170 171 172 |
# File 'app/models/questionnaire.rb', line 170 def did_rsvp? ['rsvp_confirmed', 'rsvp_denied'].include? acc_status end |
#eligible_for_a_bus? ⇒ Boolean
174 175 176 |
# File 'app/models/questionnaire.rb', line 174 def eligible_for_a_bus? school.present? && school.bus_list_id? end |
#email ⇒ Object
102 103 104 |
# File 'app/models/questionnaire.rb', line 102 def email user&.email end |
#fips_code ⇒ Object
154 155 156 |
# File 'app/models/questionnaire.rb', line 154 def fips_code Fips.where(city: school.city, state: school.state).first end |
#full_location ⇒ Object
128 129 130 |
# File 'app/models/questionnaire.rb', line 128 def full_location "#{school.city}, #{school.state}" end |
#full_name ⇒ Object
124 125 126 |
# File 'app/models/questionnaire.rb', line 124 def full_name "#{first_name} #{last_name}" end |
#invite_to_slack ⇒ Object
190 191 192 |
# File 'app/models/questionnaire.rb', line 190 def invite_to_slack SlackInviteWorker.perform_async(id) end |
#message_events ⇒ Object
183 184 185 186 187 188 |
# File 'app/models/questionnaire.rb', line 183 def return [] unless ENV['SPARKPOST_API_KEY'] simple_spark = SimpleSpark::Client.new simple_spark..search(recipients: email) end |
#minor? ⇒ Boolean
162 163 164 |
# File 'app/models/questionnaire.rb', line 162 def minor? age_at_time_of_event < 18.years end |
#portfolio_url=(value) ⇒ Object
106 107 108 109 |
# File 'app/models/questionnaire.rb', line 106 def portfolio_url=(value) value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end |
#school ⇒ Object
116 117 118 |
# File 'app/models/questionnaire.rb', line 116 def school School.find(school_id) if school_id end |
#school_name ⇒ Object
120 121 122 |
# File 'app/models/questionnaire.rb', line 120 def school_name school.name if school_id end |
#vcs_url=(value) ⇒ Object
111 112 113 114 |
# File 'app/models/questionnaire.rb', line 111 def vcs_url=(value) value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end |
#verbal_status ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'app/models/questionnaire.rb', line 194 def verbal_status if acc_status == "rsvp_denied" "Not Attending" elsif acc_status == "rsvp_confirmed" "Accepted & Attending" elsif acc_status == "accepted" "Accepted, Awaiting RSVP" elsif ["pending", "waitlist", "late_waitlist"].include? acc_status "Pending Review" elsif acc_status == "denied" "Denied" end end |