Class: Effective::EventRegistrant
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::EventRegistrant
- 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", "blank_registrant", "member_or_non_member_choice", "response1", "response2", "response3"]
- MEMBER_OR_NON_MEMBER_CHOICES =
['Add a regular registration', 'Add a member registration']
Instance Method Summary collapse
- #event_ticket_price ⇒ Object
- #last_first_name ⇒ Object
-
#mark_registered! ⇒ Object
This is the Admin Save and Mark Registered action.
- #member_email ⇒ Object
- #member_or_non_member_choice ⇒ Object
- #member_present? ⇒ Boolean
- #name ⇒ Object
- #present_registrant? ⇒ Boolean
- #promote! ⇒ Object
- #qb_item_name ⇒ Object
-
#registered! ⇒ Object
Called by an event_registration after_defer and after_purchase.
- #registered? ⇒ Boolean
- #tax_exempt ⇒ Object
- #title ⇒ Object
- #to_s ⇒ Object
- #unpromote! ⇒ Object
- #unwaitlist! ⇒ Object
- #waitlist! ⇒ Object
- #waitlisted_not_promoted? ⇒ Boolean
Instance Method Details
#event_ticket_price ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'app/models/effective/event_registrant.rb', line 226 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
143 144 145 |
# File 'app/models/effective/event_registrant.rb', line 143 def last_first_name first_name.present? ? "#{last_name}, #{first_name}" : "GUEST" end |
#mark_registered! ⇒ Object
This is the Admin Save and Mark Registered action
182 183 184 |
# File 'app/models/effective/event_registrant.rb', line 182 def mark_registered! registered! end |
#member_email ⇒ Object
155 156 157 |
# File 'app/models/effective/event_registrant.rb', line 155 def member_email email.presence || user&.email end |
#member_or_non_member_choice ⇒ Object
151 152 153 |
# File 'app/models/effective/event_registrant.rb', line 151 def member_or_non_member_choice self[:member_or_non_member_choice] || 'Add a regular registration' end |
#member_present? ⇒ Boolean
147 148 149 |
# File 'app/models/effective/event_registrant.rb', line 147 def member_present? user&.is?(:member) end |
#name ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'app/models/effective/event_registrant.rb', line 133 def name if first_name.present? "#{first_name} #{last_name}" elsif owner.present? owner.to_s + ' - GUEST' else 'GUEST' end end |
#present_registrant? ⇒ Boolean
159 160 161 |
# File 'app/models/effective/event_registrant.rb', line 159 def present_registrant? !blank_registrant? end |
#promote! ⇒ Object
204 205 206 207 208 209 210 211 |
# File 'app/models/effective/event_registrant.rb', line 204 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 |
#qb_item_name ⇒ Object
167 168 169 |
# File 'app/models/effective/event_registrant.rb', line 167 def qb_item_name event_ticket&.qb_item_name end |
#registered! ⇒ Object
Called by an event_registration after_defer and after_purchase
176 177 178 179 |
# File 'app/models/effective/event_registrant.rb', line 176 def registered! self.registered_at ||= Time.zone.now save! end |
#registered? ⇒ Boolean
171 172 173 |
# File 'app/models/effective/event_registrant.rb', line 171 def registered? registered_at.present? end |
#tax_exempt ⇒ Object
163 164 165 |
# File 'app/models/effective/event_registrant.rb', line 163 def tax_exempt event_ticket&.tax_exempt end |
#title ⇒ Object
129 130 131 |
# File 'app/models/effective/event_registrant.rb', line 129 def title [event_ticket.to_s, name, ('WAITLIST' if waitlisted_not_promoted?)].compact.join(' - ') end |
#to_s ⇒ Object
125 126 127 |
# File 'app/models/effective/event_registrant.rb', line 125 def to_s persisted? ? title : 'registrant' end |
#unpromote! ⇒ Object
213 214 215 216 217 218 219 220 |
# File 'app/models/effective/event_registrant.rb', line 213 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
195 196 197 198 199 200 201 202 |
# File 'app/models/effective/event_registrant.rb', line 195 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
186 187 188 189 190 191 192 193 |
# File 'app/models/effective/event_registrant.rb', line 186 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
243 244 245 |
# File 'app/models/effective/event_registrant.rb', line 243 def waitlisted_not_promoted? (waitlisted? && !promoted?) end |