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