Skip to content

Commit

Permalink
Adding /attend/event-id short link for ticket requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster committed May 19, 2024
1 parent 314c113 commit d092843
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
12 changes: 3 additions & 9 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
class HomeController < ApplicationController
def index
most_recent_event = Event.live_events.first
error_message = 'No currently live events exist that have tickets on sale.'

if most_recent_event.present?
error_message = 'Please reach out to event coordinator to obtain the ticket request link.'
if signed_in? && current_user.present?
if current_user.site_admin? || current_user.manages_event?(most_recent_event)
# event admin —> let them manage the event
Expand All @@ -22,26 +24,18 @@ def index
end
end

# Otherwise, redirect to the ticket request page for this event
return redirect_to new_event_ticket_request_path(event_id: most_recent_event.to_param)
elsif signed_in? && current_user && (current_user.site_admin? || current_user.event_admin?)

# redirect event admins to the events listing
return redirect_to events_path
end

# If we don't have any live events, render oops.
@error_description = flash.now[:error] || no_events_message
@error_description = flash.now[:error] || error_message
render :oops
end

def oops
render
end

private

def no_events_message
'No currently live events exist that have tickets on sale.'
end
end
2 changes: 1 addition & 1 deletion app/views/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(Right click and copy the link to your clipboard)
%br
.card-body.button-links
= link_to tickets_request_url(@event), tickets_request_url(@event), class: "button-link ticket-request-link", target: "_top"
= link_to attend_event_url(@event), attend_event_url(@event), class: "button-link ticket-request-link", target: "_top"


.col-sm-12.col-md-12.col-lg-6.col-xl-6
Expand Down
5 changes: 3 additions & 2 deletions app/views/home/oops.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.hero-unit
%h1
#{@error_description}
%h2
Please ask your administrator to do so if you'd like to party soon.
- if @error_description.nil?
%h2
Please ask your administrator to do so if you'd like to party soon.

= render 'shared/marketing'
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@
resources :site_admins, only: %i[index new create destroy]

get '/tickets/request/:event_id', to: 'ticket_requests#new', as: :tickets_request
get '/attend/:event_id', to: 'ticket_requests#new', as: :attend_event
end
# rubocop: enable Metrics/BlockLength

0 comments on commit d092843

Please sign in to comment.