commit
3f324d4e6f
4 changed files with 85 additions and 0 deletions
16
app/controllers/admin/ticket_scannings_controller.rb
Normal file
16
app/controllers/admin/ticket_scannings_controller.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
module Admin
|
||||
class TicketScanningsController < Admin::BaseController
|
||||
before_action :authenticate_user!
|
||||
load_resource :physical_ticket, find_by: :token
|
||||
# We authorize manually in these actions
|
||||
skip_authorize_resource only: [:create]
|
||||
|
||||
def create
|
||||
@ticket_scanning = TicketScanning.new(physical_ticket: @physical_ticket)
|
||||
authorize! :create, @ticket_scanning
|
||||
@ticket_scanning.save
|
||||
redirect_to conferences_path,
|
||||
notice: "Ticket with token #{@physical_ticket.token} successfully scanned."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -144,6 +144,10 @@ class AdminAbility
|
|||
can :manage, Sponsor, conference_id: conf_ids
|
||||
can :manage, SponsorshipLevel, conference_id: conf_ids
|
||||
can :manage, Ticket, conference_id: conf_ids
|
||||
can :create, TicketScanning do |ticket_scanning|
|
||||
conf_id = ticket_scanning.physical_ticket.ticket_purchase.conference_id
|
||||
conf_ids.include? conf_id
|
||||
end
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
|
||||
|
|
@ -219,6 +223,10 @@ class AdminAbility
|
|||
can :manage, Question do |question|
|
||||
!(question.conferences.pluck(:id) & conf_ids_for_info_desk).empty?
|
||||
end
|
||||
can :create, TicketScanning do |ticket_scanning|
|
||||
conf_id = ticket_scanning.physical_ticket.ticket_purchase.conference_id
|
||||
conf_ids_for_info_desk.include? conf_id
|
||||
end
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue