Merge pull request #1558 from siddhantbajaj/admin-ticket
[WIP] Allow admin to show/generate ticket
This commit is contained in:
commit
eb9d799f23
5 changed files with 60 additions and 6 deletions
14
app/controllers/admin/physical_ticket_controller.rb
Normal file
14
app/controllers/admin/physical_ticket_controller.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Admin
|
||||||
|
class PhysicalTicketController < Admin::BaseController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
load_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource
|
||||||
|
authorize_resource :conference_registrations, class: Registration
|
||||||
|
|
||||||
|
def index
|
||||||
|
@physical_tickets = @conference.physical_tickets
|
||||||
|
@tickets_sold_distribution = @conference.tickets_sold_distribution
|
||||||
|
@tickets_turnover_distribution = @conference.tickets_turnover_distribution
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -56,7 +56,7 @@ class Ticket < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def tickets_sold
|
def tickets_sold
|
||||||
ticket_purchases.sum(:quantity)
|
ticket_purchases.paid.sum(:quantity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tickets_turnover
|
def tickets_turnover
|
||||||
|
|
|
||||||
43
app/views/admin/physical_ticket/index.html.haml
Normal file
43
app/views/admin/physical_ticket/index.html.haml
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
.container
|
||||||
|
.row
|
||||||
|
.col-md-12.page-header
|
||||||
|
%h2
|
||||||
|
Tickets Sold
|
||||||
|
.text-muted
|
||||||
|
Tickets sold for the conference
|
||||||
|
.row
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'admin/conferences/doughnut_chart',
|
||||||
|
locals: { title: 'Tickets sold', data: @tickets_sold_distribution }
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'admin/conferences/doughnut_chart',
|
||||||
|
locals: {title: 'Tickets turnover', data: @tickets_turnover_distribution}
|
||||||
|
%br
|
||||||
|
- if @physical_tickets.any?
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%table.table.table-hover.datatable#tickets
|
||||||
|
%thead
|
||||||
|
%th ID
|
||||||
|
%th Type
|
||||||
|
%th User
|
||||||
|
%th Actions
|
||||||
|
%tbody
|
||||||
|
- @physical_tickets.each do |physical_ticket|
|
||||||
|
%tr
|
||||||
|
%td= physical_ticket.id
|
||||||
|
%td= physical_ticket.ticket.title
|
||||||
|
%td= physical_ticket.user.email
|
||||||
|
%td
|
||||||
|
.btn-group
|
||||||
|
= link_to 'Show',
|
||||||
|
conference_physical_ticket_path(@conference.short_title,
|
||||||
|
physical_ticket.id),
|
||||||
|
class: 'btn btn-primary'
|
||||||
|
= link_to 'Generate PDF',
|
||||||
|
conference_physical_ticket_path(@conference.short_title,
|
||||||
|
physical_ticket.id,
|
||||||
|
format: :pdf),
|
||||||
|
class: 'button btn btn-default btn-info'
|
||||||
|
- else
|
||||||
|
%h5 No Tickets sold!
|
||||||
|
|
@ -4,11 +4,6 @@
|
||||||
%h1 Tickets
|
%h1 Tickets
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
Tickets to get during registration
|
Tickets to get during registration
|
||||||
.row
|
|
||||||
.col-md-4
|
|
||||||
= render partial: 'admin/conferences/doughnut_chart', locals: { title: 'Tickets sold', data: @tickets_sold_distribution,}
|
|
||||||
.col-md-4
|
|
||||||
= render partial: 'admin/conferences/doughnut_chart', locals: { title: 'Tickets turnover', data: @tickets_turnover_distribution }
|
|
||||||
%br
|
%br
|
||||||
- if @conference.tickets.any?
|
- if @conference.tickets.any?
|
||||||
.row
|
.row
|
||||||
|
|
@ -42,3 +37,4 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= link_to 'Add Ticket', new_admin_conference_ticket_path, class: 'btn btn-success pull-right'
|
= link_to 'Add Ticket', new_admin_conference_ticket_path, class: 'btn btn-success pull-right'
|
||||||
|
= link_to 'Tickets Sold', admin_conference_physical_ticket_index_path, class: 'button btn btn-default btn-info pull-right'
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ Osem::Application.routes.draw do
|
||||||
resources :targets, except: [:show]
|
resources :targets, except: [:show]
|
||||||
resources :campaigns, except: [:show]
|
resources :campaigns, except: [:show]
|
||||||
resources :emails, only: [:show, :update, :index]
|
resources :emails, only: [:show, :update, :index]
|
||||||
|
resources :physical_ticket, only: [:index]
|
||||||
resources :roles, except: [ :new, :create ] do
|
resources :roles, except: [ :new, :create ] do
|
||||||
member do
|
member do
|
||||||
post :toggle_user
|
post :toggle_user
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue