Class: Effective::EventRegistrant
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::EventRegistrant
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/models/effective/event_registrant.rb
Constant Summary collapse
- PERMITTED_BLANK_REGISTRANT_CHANGES =
["first_name", "last_name", "email", "company", "user_id", "user_type", "organization_id", "organization_type", "blank_registrant", "response1", "response2", "response3"]
Instance Attribute Summary collapse
-
#building_user_and_organization ⇒ Object
Returns the value of attribute building_user_and_organization.
Instance Method Summary collapse
- #archive! ⇒ Object
- #details ⇒ Object
- #event_ticket_price ⇒ Object
- #last_first_name ⇒ Object
-
#mark_registered! ⇒ Object
This is the Admin Save and Mark Registered action.
- #member_present? ⇒ Boolean
- #member_ticket? ⇒ Boolean
- #name ⇒ Object
- #present_registrant? ⇒ Boolean
- #promote! ⇒ Object
- #purchasable_name ⇒ Object
- #qb_item_name ⇒ Object
-
#registered! ⇒ Object
Called by an event_registration after_defer and after_purchase.
- #registered? ⇒ Boolean
-
#registrant_validations_enabled? ⇒ Boolean
We create registrants on the tickets step.
- #selected? ⇒ Boolean
- #selected_not_expired? ⇒ Boolean
- #tax_exempt ⇒ Object
- #title ⇒ Object
- #to_s ⇒ Object
- #unarchive! ⇒ Object
- #unpromote! ⇒ Object
- #unwaitlist! ⇒ Object
- #waitlist! ⇒ Object
- #waitlisted_not_promoted? ⇒ Boolean
Instance Attribute Details
#building_user_and_organization ⇒ Object
Returns the value of attribute building_user_and_organization.
11 12 13 |
# File 'app/models/effective/event_registrant.rb', line 11 def building_user_and_organization @building_user_and_organization end |
Instance Method Details
#archive! ⇒ Object
290 291 292 293 294 |
# File 'app/models/effective/event_registrant.rb', line 290 def archive! super() orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#details ⇒ Object
180 181 182 183 184 185 186 |
# File 'app/models/effective/event_registrant.rb', line 180 def details [ (content_tag(:span, 'Member', class: 'badge badge-warning') if member_ticket?), (content_tag(:span, 'Waitlist', class: 'badge badge-warning') if waitlisted_not_promoted?), (content_tag(:span, 'Archived', class: 'badge badge-warning') if archived?) ].compact.join(' ').html_safe end |
#event_ticket_price ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'app/models/effective/event_registrant.rb', line 302 def event_ticket_price raise('expected an event') if event.blank? raise('expected an event ticket') if event_ticket.blank? if event.early_bird? event_ticket.early_bird_price # Early Bird Pricing elsif event_ticket.regular? event_ticket.regular_price elsif event_ticket.member_only? event_ticket.member_price elsif event_ticket.member_or_non_member? (member_present? ? event_ticket.member_price : event_ticket.regular_price) else raise("Unexpected event ticket price calculation") end end |
#last_first_name ⇒ Object
192 193 194 |
# File 'app/models/effective/event_registrant.rb', line 192 def last_first_name (first_name.present? && last_name.present?) ? "#{last_name}, #{first_name}" : "GUEST" end |
#mark_registered! ⇒ Object
This is the Admin Save and Mark Registered action
250 251 252 |
# File 'app/models/effective/event_registrant.rb', line 250 def mark_registered! registered! end |
#member_present? ⇒ Boolean
206 207 208 |
# File 'app/models/effective/event_registrant.rb', line 206 def member_present? user.try(:membership_present?) || organization.try(:membership_present?) end |
#member_ticket? ⇒ Boolean
210 211 212 213 214 215 216 |
# File 'app/models/effective/event_registrant.rb', line 210 def member_ticket? return false if event_ticket.blank? return true if event_ticket.member_only? return true if event_ticket.member_or_non_member? && member_present? false end |
#name ⇒ Object
170 171 172 173 174 175 176 177 178 |
# File 'app/models/effective/event_registrant.rb', line 170 def name if first_name.present? "#{first_name} #{last_name}" elsif owner.present? owner.to_s + ' - GUEST' else 'GUEST' end end |
#present_registrant? ⇒ Boolean
218 219 220 |
# File 'app/models/effective/event_registrant.rb', line 218 def present_registrant? !blank_registrant? end |
#promote! ⇒ Object
272 273 274 275 276 277 278 279 |
# File 'app/models/effective/event_registrant.rb', line 272 def promote! raise('expected a waitlist? event_ticket') unless event_ticket.waitlist? update!(promoted: true) orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#purchasable_name ⇒ Object
188 189 190 |
# File 'app/models/effective/event_registrant.rb', line 188 def purchasable_name ["#{event_ticket} - #{name}", details.presence].compact.join('<br>').html_safe end |
#qb_item_name ⇒ Object
226 227 228 |
# File 'app/models/effective/event_registrant.rb', line 226 def qb_item_name event_ticket&.qb_item_name end |
#registered! ⇒ Object
Called by an event_registration after_defer and after_purchase
244 245 246 247 |
# File 'app/models/effective/event_registrant.rb', line 244 def registered! self.registered_at ||= Time.zone.now save! end |
#registered? ⇒ Boolean
234 235 236 |
# File 'app/models/effective/event_registrant.rb', line 234 def registered? registered_at.present? end |
#registrant_validations_enabled? ⇒ Boolean
We create registrants on the tickets step. But don’t enforce validations until the details step.
197 198 199 200 201 202 203 204 |
# File 'app/models/effective/event_registrant.rb', line 197 def registrant_validations_enabled? return false if blank_registrant? # They want to come back later return true if event_registration.blank? # If we're creating in an Admin area return false if event_ticket.blank? # Invalid anyway event_registration.current_step == :details end |
#selected? ⇒ Boolean
230 231 232 |
# File 'app/models/effective/event_registrant.rb', line 230 def selected? selected_at.present? end |
#selected_not_expired? ⇒ Boolean
238 239 240 241 |
# File 'app/models/effective/event_registrant.rb', line 238 def selected_not_expired? return false unless EffectiveEvents.EventRegistration.selection_window.present? selected_at.present? && (selected_at + EffectiveEvents.EventRegistration.selection_window > Time.zone.now) end |
#tax_exempt ⇒ Object
222 223 224 |
# File 'app/models/effective/event_registrant.rb', line 222 def tax_exempt event_ticket&.tax_exempt end |
#title ⇒ Object
166 167 168 |
# File 'app/models/effective/event_registrant.rb', line 166 def title ["#{event_ticket} - #{name}", details.presence].compact.join(' ').html_safe end |
#to_s ⇒ Object
162 163 164 |
# File 'app/models/effective/event_registrant.rb', line 162 def to_s persisted? ? title : 'registrant' end |
#unarchive! ⇒ Object
296 297 298 299 300 |
# File 'app/models/effective/event_registrant.rb', line 296 def unarchive! super() orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#unpromote! ⇒ Object
281 282 283 284 285 286 287 288 |
# File 'app/models/effective/event_registrant.rb', line 281 def unpromote! raise('expected a waitlist? event_ticket') unless event_ticket.waitlist? update!(promoted: false) orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#unwaitlist! ⇒ Object
263 264 265 266 267 268 269 270 |
# File 'app/models/effective/event_registrant.rb', line 263 def unwaitlist! raise('expected a waitlist? event_ticket') unless event_ticket.waitlist? update!(waitlisted: false) orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#waitlist! ⇒ Object
254 255 256 257 258 259 260 261 |
# File 'app/models/effective/event_registrant.rb', line 254 def waitlist! raise('expected a waitlist? event_ticket') unless event_ticket.waitlist? update!(waitlisted: true) orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#waitlisted_not_promoted? ⇒ Boolean
319 320 321 |
# File 'app/models/effective/event_registrant.rb', line 319 def waitlisted_not_promoted? (waitlisted? && !promoted?) end |