Skip to content

Commit

Permalink
big nav cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
beingmattlevy committed Jul 30, 2024
1 parent 6b03207 commit 364ba22
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 57 deletions.
Binary file added app/assets/images/icons/pass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions app/controllers/ticket_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ def index
requests = @ticket_requests.select { |tr| tr.send("#{status}?") }

stats[status] = {
requests: requests.count,
adults: requests.sum(&:adults),
kids: requests.sum(&:kids),
event_addons: requests.sum(&:active_ticket_request_event_addons_count),
raised: requests.sum(&:price)
requests: requests.count,
adults: requests.sum(&:adults),
kids: requests.sum(&:kids),
addon_passes: requests.sum(&:active_addon_pass_count),
addon_camping: requests.sum(&:active_addon_camp_count),
raised: requests.sum(&:price)
}
end

@stats[:total] ||= Hash.new { |h, k| h[k] = 0 }
%i[requests adults kids event_addons raised].each do |measure|
%i[requests adults kids addon_passes addon_camping raised].each do |measure|
%i[pending awaiting_payment completed].each do |status|
@stats[:total][measure] += @stats[status][measure]
end
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/ticket_requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def help_text_for(sym)
# HACK: This copy is specific for TicketBooth--we'll have to add a
# customization so that this can be set on a per-event basis
<<-HELP
Kids 12 and under are free. They do need to be registered with name and age on the
ticket request form. Reach out to [email protected] if you have any questions.
Babes in arms are free.
Kids need to be registered with name and age on the ticket request form.
Reach out to [email protected] if you have any questions.
HELP
when :address
"We'll mail your tickets to this address."
Expand Down
19 changes: 17 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class Event < ApplicationRecord
ticket_sales_end_time: START_DATE_WITH_OFFSET[7.days],

adult_ticket_price: 220,
kid_ticket_price: 0,
kid_ticket_price: 100,

max_adult_tickets_per_request: 6,
max_kid_tickets_per_request: 0,
max_kid_tickets_per_request: 4,

tickets_require_approval: true,
allow_financial_assistance: true,
Expand Down Expand Up @@ -225,6 +225,21 @@ def active_event_addons?
event_addons.where('price > ?', 0).count.positive?
end

def active_event_addons_passes?
@addons_passes ||= active_event_addons_by_category(Addon::CATEGORY_PASS).count
end

def active_event_addons_camping?
@addons_camping ||= active_event_addons_by_category(Addon::CATEGORY_CAMP).count
end

def active_event_addons_by_category(category)
event_addons.joins(:addon, :event)
.where(event_id: id, 'addon.category' => category)
.where('price > ?', 0)
end


def active_sorted_event_addons
event_addons.where('price > ?', 0).sort_by { |e| [e.category, e.price, e.name] }
end
Expand Down
24 changes: 20 additions & 4 deletions app/models/ticket_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,33 @@ def build_ticket_request_event_addons_from_params(build_params)
ticket_request_event_addons
end

def active_sorted_ticket_request_event_addons
ticket_request_event_addons.where('quantity > ?', 0).sort_by { |e| [e.category, e.price, e.name] }
def active_addons
ticket_request_event_addons.where('quantity > ?', 0)
end

def active_sorted_addons
active_addons.sort_by { |e| [e.category, e.price, e.name] }
end

# active_ticket_request_event_addons_count
def active_ticket_request_event_addons_count
active_sorted_ticket_request_event_addons.count
active_sorted_addons.count
end

def active_addon_pass_count
@addon_pass_count ||= active_addon_by_category(Addon::CATEGORY_PASS).count
end

def active_addon_camp_count
@addon_camp_count ||= active_addon_by_category(Addon::CATEGORY_CAMP).count
end

def active_addon_by_category(category)
active_addons.select { |addon| addon.category == category }
end

def ticket_request_event_addons?
ticket_request_event_addons.where('quantity > ?', 0).count.positive?
active_addons.count.positive?
end

def set_defaults
Expand Down
20 changes: 12 additions & 8 deletions app/views/events/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
= f.text_field :name, class: 'event-name', required: true, maxlength: Event::MAX_NAME_LENGTH

= f.label :start_time, 'Start Time'
= render partial: 'shared/datetime_field', locals: {form: f, name: "start_time", datetime: (@event.start_time || 1.day.from_now.beginning_of_day) }
= render partial: 'shared/datetime_field',
locals: {form: f, name: "start_time", datetime: (@event.start_time || 1.day.from_now.beginning_of_day) }

= f.label :end_time, 'End Time'
= render partial: 'shared/datetime_field', locals: {form: f, name: "end_time", datetime: (@event.end_time || 1.day.from_now.beginning_of_day)}
= render partial: 'shared/datetime_field',
locals: {form: f, name: "end_time", datetime: (@event.end_time || 1.day.from_now.beginning_of_day)}

.vertical-20
%fieldset
Expand All @@ -21,19 +23,22 @@
Ticket Sales Opening Time
%p.muted
Leave blank to begin selling tickets right away
= render partial: 'shared/datetime_field', locals: {form: f, name: "ticket_sales_start_time", datetime: (@event.ticket_sales_start_time) }
= render partial: 'shared/datetime_field',
locals: {form: f, name: "ticket_sales_start_time", datetime: (@event.ticket_sales_start_time) }

= f.label :ticket_sales_end_time do
Ticket Sales Closing Time
%p.muted
Leave blank to allow selling tickets up to the end of the event
= render partial: 'shared/datetime_field', locals: {form: f, name: "ticket_sales_end_time", datetime: (@event.ticket_sales_end_time) }
= render partial: 'shared/datetime_field',
locals: {form: f, name: "ticket_sales_end_time", datetime: (@event.ticket_sales_end_time) }

= f.label :ticket_requests_end_time do
Ticket Requests Closing Time
%p.muted
Leave blank to allow requesting tickets up to the end of the event
= render partial: 'shared/datetime_field', locals: {form: f, name: "ticket_requests_end_time", datetime: (@event.ticket_requests_end_time) }
= render partial: 'shared/datetime_field',
locals: {form: f, name: "ticket_requests_end_time", datetime: (@event.ticket_requests_end_time) }

%legend Event Configuration
%fieldset
Expand Down Expand Up @@ -77,8 +82,7 @@
.col-sm-12.col-md-6.col-lg-6
%legend Ticket Pricing
= f.label :adult_ticket_price, 'Adult Ticket Price ($)'
= f.number_field :adult_ticket_price, class: 'input-small', required: true,
min: 0
= f.number_field :adult_ticket_price, class: 'input-small', required: true, min: 0

= f.label :max_adult_tickets_per_request do
Maximum number of adult tickets allowed per ticket request?
Expand All @@ -93,7 +97,7 @@
= f.label :max_kid_tickets_per_request do
Maximum number of kid tickets allowed per ticket request?
%p.muted Set blank for no limit
= f.number_field :max_kid_tickets_per_request, class: 'input-mini', min: 1
= f.number_field :max_kid_tickets_per_request, class: 'input-mini', min: 0

%legend Event Addons and Pricing
%p.muted
Expand Down
2 changes: 1 addition & 1 deletion app/views/payments/_payment.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

- if ticket_request.ticket_request_event_addons?
%p Event Addon:
- ticket_request.active_sorted_ticket_request_event_addons.each do |tr_event_addon|
- ticket_request.active_sorted_addons.each do |tr_event_addon|
= tr_event_addon.humanized_category
= "##{tr_event_addon.name}: #{tr_event_addon.quantity}"

Expand Down
12 changes: 9 additions & 3 deletions app/views/shared/_nav_event_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@
= link_to event_ticket_requests_path(event), class: "nav-link #{active_tab[:ticket_requests]}" do
Ticket Requests

%li.nav-item
= link_to event_ticket_requests_path(event), class: "nav-link #{active_tab[:passes]}" do
Passes
-# XXX Re-enable me when ready
-# %li.nav-item
-# = link_to event_ticket_requests_path(event), class: "nav-link #{active_tab[:passes]}" do
-# Event Passes
-# %li.nav-item
-# = link_to event_ticket_requests_path(event), class: "nav-link #{active_tab[:passes]}" do
-# Camping Permits
%li.nav-item
= link_to guest_list_event_path(event), class: "nav-link #{active_tab[:guest_list]}" do
Expand Down
4 changes: 1 addition & 3 deletions app/views/ticket_requests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
%tbody.m-0.p-0
%tr.align-middle
%td.w-90.m-0.p-0.text-start
= f.label :kids do
Number of children (12 and under) you are bringing with you
(not transferable to adults; babes in arms are free)
= f.label :kids, 'Number of Kids (13 and under) Tickets' + " @ $#{@event.kid_ticket_price.to_i} each"
= f.number_field :kids, class: 'input-mini', min: 0,
max: @event.max_kid_tickets_per_request,
data: { default_price: @event.kid_ticket_price.to_i,
Expand Down
33 changes: 23 additions & 10 deletions app/views/ticket_requests/_table_ticket_request_statuses.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
%th.bg-dark-subtle.text-end Tickets
- if event.kid_ticket_price
%th.bg-dark-subtle.text-end Kids
- if event.active_event_addons?
%th.bg-dark-subtle.text-end Addons
- if event.active_event_addons_passes?
%th.bg-dark-subtle.text-end
=Addon::HUMANIZED_CATEGORIES[Addon::CATEGORY_PASS]
- if event.active_event_addons_camping?
%th.bg-dark-subtle.text-end
=Addon::HUMANIZED_CATEGORIES[Addon::CATEGORY_CAMP]
%th.bg-dark-subtle.text-end Earn

%tbody.border-2.border-dark-subtle
Expand All @@ -37,9 +41,12 @@
- if event.kid_ticket_price
%td.text-end.bg-success-subtle
%span= stats[:completed][:kids]
- if event.active_event_addons?
- if event.active_event_addons_passes?
%td.text-end.bg-success-subtle
%span= stats[:completed][:event_addons]
%span= stats[:completed][:addon_passes]
- if event.active_event_addons_camping?
%td.text-end.bg-success-subtle
%span= stats[:completed][:addon_camping]
%td.text-end.bg-success-subtle
%span
= number_to_currency(stats[:completed][:raised], precision: 0)
Expand All @@ -51,8 +58,10 @@
%td.text-end.bg-warning= stats[:pending][:adults]
- if event.kid_ticket_price
%td.text-end.bg-warning= stats[:pending][:kids]
- if event.active_event_addons?
%td.text-end.bg-warning= stats[:pending][:event_addons]
- if event.active_event_addons_passes?
%td.text-end.bg-warning= stats[:pending][:addon_passes]
- if event.active_event_addons_camping?
%td.text-end.bg-warning= stats[:pending][:addon_camping]
%td.text-end.bg-warning.fs-6
= number_to_currency(stats[:pending][:raised], precision: 0)

Expand All @@ -63,8 +72,10 @@
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:adults]
- if event.kid_ticket_price
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:kids]
- if event.active_event_addons?
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:event_addons]
- if event.active_event_addons_passes?
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:addon_passes]
- if event.active_event_addons_camping?
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:addon_camping]
%td.text-end.bg-warning-subtle.fs-6
= number_to_currency(stats[:awaiting_payment][:raised], precision: 0)

Expand All @@ -76,6 +87,8 @@
%td.bg-dark-subtle.text-end= stats[:total][:adults]
- if event.kid_ticket_price
%td.bg-dark-subtle.text-end= stats[:total][:kids]
- if event.active_event_addons?
%td.bg-dark-subtle.text-end= stats[:total][:event_addons]
- if event.active_event_addons_passes?
%td.bg-dark-subtle.text-end= stats[:total][:addon_passes]
- if event.active_event_addons_camping?
%td.bg-dark-subtle.text-end= stats[:total][:addon_camping]
%td.bg-dark-subtle.text-end.fs-5= number_to_currency(stats[:total][:raised], precision: 0)
19 changes: 5 additions & 14 deletions app/views/ticket_requests/_table_ticket_requests.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
- if ticket_request.needs_assistance
= tooltip_box('Financial Assistance was requested.') do
= image_tag('icons/dollar.png', width: 20, class: 'hover-tooltip')
- if ticket_request.ticket_request_event_addons?
-# TODO: use different tool tips here
= tooltip_box(ticket_request.active_ticket_request_event_addons_count, title: "Addons:") do
- if ticket_request.active_addon_camp_count
= tooltip_box(ticket_request.active_addon_camp_count, title: "Camping:") do
= image_tag('icons/car.png', width: 20, class: 'hover-tooltip')
- if ticket_request.active_addon_pass_count
= tooltip_box(ticket_request.active_addon_pass_count, title: "Passes:") do
= image_tag('icons/pass.png', width: 20, class: 'hover-tooltip')
- if ticket_request.admin_notes.present?
= tooltip_box(ticket_request.admin_notes, title: "Admin Notes") do
= image_tag('icons/comments-admin.png', width: 20, class: 'hover-tooltip')
Expand All @@ -57,17 +59,6 @@
- if event.active_event_addons?
%td.align-content-center.text-end.optional-medium= ticket_request.active_ticket_request_event_addons_count
-# - if event.eald?
-# %td.align-content-center.text-end.optional-medium
-# #{ticket_request.early_arrival_passes} / #{ticket_request.late_departure_passes}
-# -# %br
-# -# - if eald_requested?(ticket_request)
-# -# - if eald_paid?(ticket_request)
-# -# ✔︎ EALD Paid
-# -# - else
-# -# ✘ Not All EALD Bought
-# -# - else
-# -# ✘ Not Requested
%td.align-content-center.text-end
%span{ class: ('label label-info' if ticket_request.special_price) }
= number_to_currency(ticket_request.price, precision: 0)
Expand Down
7 changes: 3 additions & 4 deletions app/views/ticket_requests/_ticket_request_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@
= ticket_request.kids

- if ticket_request.ticket_request_event_addons?
- ticket_request.active_sorted_ticket_request_event_addons.each do |tr_event_addon|
- ticket_request.active_sorted_addons.each do |tr_event_addon|
%tr
%td.text-end.small.p-2.px-4.text-nowrap
= tr_event_addon.humanized_category
Addon:
= tr_event_addon.humanized_category + ':'
%td
%strong
= tr_event_addon.name
= "#{tr_event_addon.quantity} - #{tr_event_addon.name}"

- if ticket_request.donation&.positive?
%tr
Expand Down

0 comments on commit 364ba22

Please sign in to comment.