Class: Questionnaire

Inherits:
ApplicationRecord
  • Object
show all
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

Instance Method Summary collapse

Instance Method Details

#acc_status_author ⇒ Object



112
113
114
115
# File 'app/models/questionnaire.rb', line 112

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

#age_at_time_of_event ⇒ Object



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

def age_at_time_of_event
  (Rails.configuration.hackathon['event_start_date'] - date_of_birth).to_i * 1.day
end

#boarded_bus? ⇒ Boolean

Returns:

  • (Boolean)


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

def boarded_bus?
  boarded_bus_at.present?
end

#bus_list ⇒ Object



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

def bus_list
  return unless eligible_for_a_bus?
  school.bus_list
end

#can_rsvp? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#checked_in? ⇒ Boolean

Returns:

  • (Boolean)


117
118
119
# File 'app/models/questionnaire.rb', line 117

def checked_in?
  checked_in_at.present?
end

#checked_in_by ⇒ Object



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

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

#date_of_birth_formatted ⇒ Object



108
109
110
# File 'app/models/questionnaire.rb', line 108

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

#did_rsvp? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#eligible_for_a_bus? ⇒ Boolean

Returns:

  • (Boolean)


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

def eligible_for_a_bus?
  school.present? && school.bus_list_id?
end

#email ⇒ Object



78
79
80
# File 'app/models/questionnaire.rb', line 78

def email
  user.email
end

#fips_code ⇒ Object



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

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

#full_location ⇒ Object



104
105
106
# File 'app/models/questionnaire.rb', line 104

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

#full_name ⇒ Object



100
101
102
# File 'app/models/questionnaire.rb', line 100

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

#invite_to_slack ⇒ Object



166
167
168
# File 'app/models/questionnaire.rb', line 166

def invite_to_slack
  SlackInviteWorker.perform_async(id)
end

#message_events ⇒ Object



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

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)


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

def minor?
  age_at_time_of_event < 18.years
end

#portfolio_url=(value) ⇒ Object



82
83
84
85
# File 'app/models/questionnaire.rb', line 82

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

#school ⇒ Object



92
93
94
# File 'app/models/questionnaire.rb', line 92

def school
  School.find(school_id) if school_id
end

#school_name ⇒ Object



96
97
98
# File 'app/models/questionnaire.rb', line 96

def school_name
  school.name if school_id
end

#vcs_url=(value) ⇒ Object



87
88
89
90
# File 'app/models/questionnaire.rb', line 87

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

#verbal_status ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'app/models/questionnaire.rb', line 170

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