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
287 288 289 290 291 |
# File 'app/models/effective/event_registrant.rb', line 287 def archive! super() orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#details ⇒ Object
177 178 179 180 181 182 183 |
# File 'app/models/effective/event_registrant.rb', line 177 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
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'app/models/effective/event_registrant.rb', line 299 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
189 190 191 |
# File 'app/models/effective/event_registrant.rb', line 189 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
247 248 249 |
# File 'app/models/effective/event_registrant.rb', line 247 def mark_registered! registered! end |
#member_present? ⇒ Boolean
203 204 205 |
# File 'app/models/effective/event_registrant.rb', line 203 def member_present? user.try(:membership_present?) || organization.try(:membership_present?) end |
#member_ticket? ⇒ Boolean
207 208 209 210 211 212 213 |
# File 'app/models/effective/event_registrant.rb', line 207 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
167 168 169 170 171 172 173 174 175 |
# File 'app/models/effective/event_registrant.rb', line 167 def name if first_name.present? "#{first_name} #{last_name}" elsif owner.present? owner.to_s + ' - GUEST' else 'GUEST' end end |
#present_registrant? ⇒ Boolean
215 216 217 |
# File 'app/models/effective/event_registrant.rb', line 215 def present_registrant? !blank_registrant? end |
#promote! ⇒ Object
269 270 271 272 273 274 275 276 |
# File 'app/models/effective/event_registrant.rb', line 269 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
185 186 187 |
# File 'app/models/effective/event_registrant.rb', line 185 def purchasable_name ["#{event_ticket} - #{name}", details.presence].compact.join('<br>').html_safe end |
#qb_item_name ⇒ Object
223 224 225 |
# File 'app/models/effective/event_registrant.rb', line 223 def qb_item_name event_ticket&.qb_item_name end |
#registered! ⇒ Object
Called by an event_registration after_defer and after_purchase
241 242 243 244 |
# File 'app/models/effective/event_registrant.rb', line 241 def registered! self.registered_at ||= Time.zone.now save! end |
#registered? ⇒ Boolean
231 232 233 |
# File 'app/models/effective/event_registrant.rb', line 231 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.
194 195 196 197 198 199 200 201 |
# File 'app/models/effective/event_registrant.rb', line 194 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
227 228 229 |
# File 'app/models/effective/event_registrant.rb', line 227 def selected? selected_at.present? end |
#selected_not_expired? ⇒ Boolean
235 236 237 238 |
# File 'app/models/effective/event_registrant.rb', line 235 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
219 220 221 |
# File 'app/models/effective/event_registrant.rb', line 219 def tax_exempt event_ticket&.tax_exempt end |
#title ⇒ Object
163 164 165 |
# File 'app/models/effective/event_registrant.rb', line 163 def title ["#{event_ticket} - #{name}", details.presence].compact.join(' ').html_safe end |
#to_s ⇒ Object
159 160 161 |
# File 'app/models/effective/event_registrant.rb', line 159 def to_s persisted? ? title : 'registrant' end |
#unarchive! ⇒ Object
293 294 295 296 297 |
# File 'app/models/effective/event_registrant.rb', line 293 def unarchive! super() orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! } true end |
#unpromote! ⇒ Object
278 279 280 281 282 283 284 285 |
# File 'app/models/effective/event_registrant.rb', line 278 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
260 261 262 263 264 265 266 267 |
# File 'app/models/effective/event_registrant.rb', line 260 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
251 252 253 254 255 256 257 258 |
# File 'app/models/effective/event_registrant.rb', line 251 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
316 317 318 |
# File 'app/models/effective/event_registrant.rb', line 316 def waitlisted_not_promoted? (waitlisted? && !promoted?) end |