Class: Questionnaire

Inherits:
ApplicationRecord
  • Object
show all
Includes:
ActiveModel::Dirty, DeletableAttachment
Defined in:
app/models/questionnaire.rb

Constant Summary collapse

DIETARY_SPECIAL_NEEDS_MAX_LENGTH =
500
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_GRAD_YEARS =
(Date.today.year - 3...Date.today.year + 7).to_a.freeze
POSSIBLE_RACE_ETHNICITIES =
[
  "American Indian or Alaskan Native",
  "Asian / Pacific Islander",
  "Black or African American",
  "Hispanic",
  "White / Caucasian",
  "Multiple ethnicities / Other",
  "Prefer not to answer"
].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

Instance Method Details

#acc_status_authorObject



155
156
157
158
# File 'app/models/questionnaire.rb', line 155

def acc_status_author
  return unless acc_status_author_id.present?
  User.find(acc_status_author_id)
end

#age_at_time_of_eventObject



177
178
179
# File 'app/models/questionnaire.rb', line 177

def age_at_time_of_event
  (Date.parse(HackathonConfig['event_start_date']) - date_of_birth).to_i * 1.day
end

#boarded_bus?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'app/models/questionnaire.rb', line 164

def boarded_bus?
  boarded_bus_at.present?
end

#can_rsvp?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'app/models/questionnaire.rb', line 185

def can_rsvp?
  ["accepted", "rsvp_confirmed", "rsvp_denied"].include? acc_status
end

#checked_in?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'app/models/questionnaire.rb', line 160

def checked_in?
  checked_in_at.present?
end

#checked_in_byObject



168
169
170
171
# File 'app/models/questionnaire.rb', line 168

def checked_in_by
  return unless checked_in_by_id.present?
  User.find(checked_in_by_id)
end

#date_of_birth_formattedObject



151
152
153
# File 'app/models/questionnaire.rb', line 151

def date_of_birth_formatted
  date_of_birth.strftime("%B %-d, %Y")
end

#did_rsvp?Boolean

Returns:

  • (Boolean)


189
190
191
# File 'app/models/questionnaire.rb', line 189

def did_rsvp?
  ['rsvp_confirmed', 'rsvp_denied'].include? acc_status
end

#emailObject



121
122
123
# File 'app/models/questionnaire.rb', line 121

def email
  user&.email
end

#fips_codeObject



173
174
175
# File 'app/models/questionnaire.rb', line 173

def fips_code
  Fips.where(city: school.city, state: school.state).first
end

#full_locationObject



147
148
149
# File 'app/models/questionnaire.rb', line 147

def full_location
  "#{school.city}, #{school.state}"
end

#full_nameObject



143
144
145
# File 'app/models/questionnaire.rb', line 143

def full_name
  "#{first_name} #{last_name}"
end

#message_eventsObject



193
194
195
196
197
198
# File 'app/models/questionnaire.rb', line 193

def message_events
  return [] unless ENV['SPARKPOST_API_KEY']

  simple_spark = SimpleSpark::Client.new
  simple_spark.message_events.search(recipients: email)
end

#minor?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'app/models/questionnaire.rb', line 181

def minor?
  age_at_time_of_event < 18.years
end

#portfolio_url=(value) ⇒ Object



125
126
127
128
# File 'app/models/questionnaire.rb', line 125

def portfolio_url=(value)
  value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
  super value
end

#schoolObject



135
136
137
# File 'app/models/questionnaire.rb', line 135

def school
  School.find(school_id) if school_id
end

#school_nameObject



139
140
141
# File 'app/models/questionnaire.rb', line 139

def school_name
  school.name if school_id
end

#vcs_url=(value) ⇒ Object



130
131
132
133
# File 'app/models/questionnaire.rb', line 130

def vcs_url=(value)
  value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
  super value
end

#verbal_statusObject



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'app/models/questionnaire.rb', line 200

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 acc_status == "pending"
    "Pending Review"
  elsif ["waitlist", "late_waitlist"].include? acc_status
    "Waitlisted"
  elsif acc_status == "denied"
    "Denied"
  end
end