mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Added Token field for physical_ticket
Added token field in physical_ticket model. This token will also be stored in the qr code and will uniqely identify the ticket.
This commit is contained in:
parent
0528dbf8e8
commit
9e154a1dcd
8 changed files with 33 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
class PhysicalTicketController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource
|
||||
load_and_authorize_resource find_by: :token
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
|
||||
def index
|
||||
|
|
|
|||
|
|
@ -4,4 +4,19 @@ class PhysicalTicket < ActiveRecord::Base
|
|||
has_one :conference, through: :ticket_purchase
|
||||
has_one :user, through: :ticket_purchase
|
||||
has_many :ticket_scannings
|
||||
|
||||
before_create :set_token
|
||||
|
||||
private
|
||||
|
||||
def set_token
|
||||
self.token = generate_token
|
||||
end
|
||||
|
||||
def generate_token
|
||||
loop do
|
||||
token = SecureRandom.hex(10)
|
||||
break token unless PhysicalTicket.exists?(token: token)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@
|
|||
.btn-group
|
||||
= link_to 'Show',
|
||||
conference_physical_ticket_path(@conference.short_title,
|
||||
physical_ticket.id),
|
||||
physical_ticket.token),
|
||||
class: 'btn btn-primary'
|
||||
= link_to 'Generate PDF',
|
||||
conference_physical_ticket_path(@conference.short_title,
|
||||
physical_ticket.id,
|
||||
format: :pdf),
|
||||
physical_ticket.token,
|
||||
format: :pdf),
|
||||
class: 'button btn btn-default btn-info'
|
||||
- else
|
||||
%h5 No Tickets sold!
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@
|
|||
.btn-group
|
||||
= link_to 'Show',
|
||||
conference_physical_ticket_path(@conference.short_title,
|
||||
physical_ticket.id),
|
||||
physical_ticket.token),
|
||||
class: 'btn btn-primary'
|
||||
= link_to 'Generate PDF',
|
||||
conference_physical_ticket_path(@conference.short_title,
|
||||
physical_ticket.id,
|
||||
physical_ticket.token,
|
||||
format: :pdf),
|
||||
class: 'button btn btn-default btn-info'
|
||||
- else
|
||||
|
|
|
|||
|
|
@ -72,6 +72,6 @@
|
|||
%p.text-left
|
||||
= link_to 'Generate PDF',
|
||||
conference_physical_ticket_path(@conference.short_title,
|
||||
@physical_ticket.id,
|
||||
@physical_ticket.token,
|
||||
format: :pdf),
|
||||
class: 'button btn btn-default btn-info'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue