Add (admin-only) tickets via 'visibile' attribute [migration]
(cherry picked from commit ce0db3d7a736e7bcde480721986dbfb4a82aa083)
This commit is contained in:
parent
1fcd5c68c5
commit
26f0377c76
15 changed files with 56 additions and 10 deletions
|
|
@ -52,7 +52,12 @@ module Admin
|
|||
private
|
||||
|
||||
def ticket_params
|
||||
params.require(:ticket).permit(:conference, :title, :url, :description, :conference_id, :price_cents, :price_currency, :price, :registration_ticket)
|
||||
params.require(:ticket).permit(
|
||||
:conference, :conference_id,
|
||||
:title, :url, :description,
|
||||
:price_cents, :price_currency, :price,
|
||||
:registration_ticket, :visible
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
sign_in(@registration.user)
|
||||
end
|
||||
|
||||
if @conference.tickets.any? && !current_user.supports?(@conference)
|
||||
if @conference.tickets.visible.any? && !current_user.supports?(@conference)
|
||||
redirect_to conference_tickets_path(@conference.short_title),
|
||||
notice: 'You are now registered and will be receiving E-Mail notifications.'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ConferencesController < ApplicationController
|
|||
end
|
||||
end
|
||||
if splashpage.include_registrations || splashpage.include_tickets
|
||||
@tickets = @conference.tickets.order('price_cents')
|
||||
@tickets = @conference.tickets.visible.order('price_cents')
|
||||
end
|
||||
if splashpage.include_lodgings
|
||||
@lodgings = @conference.lodgings.order('name')
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
class TicketsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_resource :ticket, through: :conference
|
||||
before_action :load_tickets
|
||||
authorize_resource :ticket, through: :conference
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
before_action :check_load_resource, only: :index
|
||||
|
||||
|
|
@ -14,4 +15,8 @@ class TicketsController < ApplicationController
|
|||
redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!"
|
||||
end
|
||||
end
|
||||
|
||||
def load_tickets
|
||||
@tickets = @conference.tickets.visible
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue