Skip to content

Commit

Permalink
Support checking in tickets + show the physical tickets page
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Jul 17, 2023
1 parent 162d25d commit 96f0e38
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/controllers/admin/ticket_scannings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
module Admin
class TicketScanningsController < Admin::BaseController
before_action :authenticate_user!
load_resource :physical_ticket, find_by: :token
# load_resource :physical_ticket, find_by: :token
# We authorize manually in these actions
skip_authorize_resource only: [:create]

def create
puts "CREATE CALLED #{params}"
@physical_ticket = PhysicalTicket.find_by(token: params[:physical_ticket][:token])
debugger
@ticket_scanning = TicketScanning.new(physical_ticket: @physical_ticket)
authorize! :create, @ticket_scanning
@ticket_scanning.save
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/date_time_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def format_datetime(obj)
obj.strftime('%Y-%m-%d %H:%M')
end

def format_all_timestamps(lst, conference)
lst.map do |ts|
"#{format_datetime(ts.in_time_zone(conference.timezone))} #{timezone_text(conference)}"
end.to_sentence
end

def show_time(length)
return '0 h 0 min' if length.blank?

Expand Down
20 changes: 18 additions & 2 deletions app/views/admin/physical_tickets/_physical_ticket.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
%tr
%td= physical_ticket.id
%td= physical_ticket.ticket.title
%td= physical_ticket.user.email
%td= physical_ticket.ticket.registration_ticket? ? 'Yes' : 'No'
%td= physical_ticket.user&.email
%td= humanized_money_with_symbol physical_ticket.ticket_purchase.amount_paid
%td
- if physical_ticket.ticket_scannings.present?
%span Checked in:
%br
= format_all_timestamps(physical_ticket.ticket_scannings.pluck(:created_at), conference)
= form_for(physical_ticket, url: admin_ticket_scanning_path, method: :post) do |f|
= f.hidden_field 'token'
= f.submit "Mark Present", { class: 'btn btn-success' }
-# %form{method: "post", action: admin_ticket_scanning_path}
-# %input{type: "hidden", name: "token", value: physical_ticket.token}
-# %input{type: "submit", class: 'btn btn-success', value: "Mark Present"}
-# = button_to('Mark Attended',
-# admin_ticket_scanning_path(token: physical_ticket.token),
-# method: :post,
-# class: 'btn btn-success')
%td
.btn-group
= link_to 'Show',
Expand All @@ -13,4 +29,4 @@
conference_physical_ticket_path(conference.short_title,
physical_ticket.token,
format: :pdf),
class: 'button btn btn-default btn-info'
class: 'button btn btn-info'
2 changes: 2 additions & 0 deletions app/views/admin/physical_tickets/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
%thead
%th ID
%th Type
%th Registration?
%th User
%th Paid
%th Attedance
%th Actions
%tbody
- @physical_tickets.each do |physical_ticket|
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/tickets/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
%th Affiliation
%th Paid
%th Date
%th
%span.sr-only Delete
%tbody
- @ticket.buyers.each_with_index do |buyer, index|
- purchases = buyer.ticket_purchases.where(ticket_id: @ticket.id)
Expand All @@ -45,6 +48,8 @@
= @ticket.tickets_paid(buyer)
%td
= purchases.first.created_at
%td
= button_to()

- content_for :modals do
.modal.fade{ id: "modal-give-ticket-#{@ticket.id}" }
Expand Down
4 changes: 4 additions & 0 deletions app/views/layouts/_admin_sidebar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
- if can? :update, @conference.tickets.build
%li{class: active_nav_li(admin_conference_tickets_path(@conference.short_title)) }
= link_to 'Tickets', admin_conference_tickets_path(@conference.short_title)
- if can? :update, @conference.tickets.build
%li{class: active_nav_li(admin_conference_physical_tickets_path(@conference.short_title)) }
= link_to 'Ticket Purchases', admin_conference_physical_tickets_path(@conference.short_title)

- if can? :manage, @conference.booths.build
%li
= link_to admin_conference_booths_path(@conference.short_title) do
Expand Down

0 comments on commit 96f0e38

Please sign in to comment.