Module: EffectiveEventsHelper
- Defined in:
- app/helpers/effective_events_helper.rb
Instance Method Summary collapse
- #effective_events_event_products_collection(event, namespace = nil) ⇒ Object
- #effective_events_event_schedule(event) ⇒ Object
- #effective_events_event_tickets_collection(event, namespace = nil) ⇒ Object
- #effective_events_ticket_price(event, ticket) ⇒ Object
-
#event_label ⇒ Object
Event.
-
#events_label ⇒ Object
Events.
-
#events_name_label ⇒ Object
Events.
Instance Method Details
#effective_events_event_products_collection(event, namespace = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/helpers/effective_events_helper.rb', line 67 def effective_events_event_products_collection(event, namespace = nil) raise('expected an Effective::Event') unless event.kind_of?(Effective::Event) # Allow an admin to assign archived products = (namespace == :admin) products = ( ? event.event_products : event.event_products.reject(&:archived?)) products.map do |product| title = product.to_s price = (product.price == 0 ? '$0' : price_to_currency(product.price)) remaining = (product.capacity.present? ? "#{product.capacity_available} remaining" : nil) label = [title, price, remaining].compact.join(' - ') disabled = { disabled: :disabled } unless ( || event.event_product_available?(product, quantity: 1)) [label, product.to_param, disabled].compact end end |
#effective_events_event_schedule(event) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/effective_events_helper.rb', line 18 def effective_events_event_schedule(event) if event.start_at.beginning_of_day == event.end_at.beginning_of_day "#{event.start_at.strftime("%A, %B %d, %Y ยท %l:%M%P")} - #{event.end_at.strftime("%l:%M%P")}" else "#{event.start_at.strftime("%A, %B %d, %Y")} - #{event.end_at.strftime("%A, %B %d, %Y")}" end end |
#effective_events_event_tickets_collection(event, namespace = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/effective_events_helper.rb', line 43 def effective_events_event_tickets_collection(event, namespace = nil) raise('expected an Effective::Event') unless event.kind_of?(Effective::Event) # Allow an admin to assign archived tickets = (namespace == :admin) member = current_user.try(:membership_present?) tickets = ( ? event.event_tickets : event.event_tickets.reject(&:archived?)) tickets = tickets.reject { |ticket| ticket.member_only? } unless ( || member) tickets.map do |ticket| title = ticket.to_s title = "#{title} (archived)" if ticket.archived? price = effective_events_ticket_price(event, ticket) label = [title, price].compact.join(' - ') disabled = { disabled: :disabled } unless ( || ticket.waitlist? || event.event_ticket_available?(ticket, quantity: 1)) [label, ticket.to_param, disabled].compact end end |
#effective_events_ticket_price(event, ticket) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/effective_events_helper.rb', line 26 def effective_events_ticket_price(event, ticket) raise('expected an Effective::Event') unless event.kind_of?(Effective::Event) raise('expected an Effective::EventTicket') unless ticket.kind_of?(Effective::EventTicket) prices = [ (ticket.early_bird_price if event.early_bird?), (ticket.regular_price if ticket.regular? || ticket.member_or_non_member?), (ticket.member_price if ticket.member_only? || ticket.member_or_non_member?) ].compact.sort.uniq if prices.length > 1 "#{(prices.first == 0 ? '$0' : price_to_currency(prices.first))} or #{(prices.last == 0 ? '$0' : price_to_currency(prices.last))}" else (prices.first == 0 ? '$0' : price_to_currency(prices.first)) end end |
#event_label ⇒ Object
Event
9 10 11 |
# File 'app/helpers/effective_events_helper.rb', line 9 def event_label et(Effective::Event) end |
#events_label ⇒ Object
Events
14 15 16 |
# File 'app/helpers/effective_events_helper.rb', line 14 def events_label ets(Effective::Event) end |
#events_name_label ⇒ Object
Events
4 5 6 |
# File 'app/helpers/effective_events_helper.rb', line 4 def events_name_label et('effective_events.name') end |