Merge pull request #889 from rishabhs95/admin-tickets-view

correcting ticket's details view for admin.
This commit is contained in:
Christian Bruckmayer 2016-03-18 14:34:24 -06:00
commit a9fb07cadb
4 changed files with 20 additions and 8 deletions

View file

@ -22,4 +22,7 @@ $( document ).ready(function() {
$('.quantity').change(function() {
update_price($(this));
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
});

View file

@ -48,6 +48,14 @@ class Ticket < ActiveRecord::Base
result ? result : Money.new(0, 'USD')
end
def tickets_sold
ticket_purchases.sum(:quantity)
end
def tickets_turnover
tickets_sold * price
end
private
def tickets_of_conference_have_same_currency

View file

@ -10,9 +10,9 @@
%table.table.table-hover#tickets
%thead
%th Title
%th Description
%th Price
%th Sold
%th Turnover
%th Actions
%tbody
- @conference.tickets.each do |ticket|
@ -20,12 +20,12 @@
%td
= link_to(admin_conference_ticket_path(@conference.short_title, ticket.id)) do
= ticket.title
%td
= truncate(ticket.description)
%td
= humanized_money_with_symbol ticket.price
%td
= ticket.buyers.count
= ticket.tickets_sold
%td
= humanized_money_with_symbol ticket.tickets_turnover
%td
.btn-group
= link_to 'Edit', edit_admin_conference_ticket_path(@conference.short_title, ticket.id),

View file

@ -2,10 +2,11 @@
.col-md-12
.page-header
%h1
= @ticket.title
Ticket
%small
= humanized_money_with_symbol @ticket.price
%div{"data-placement" => "left", "data-toggle" => "tooltip", :title => @ticket.description}
= @ticket.title
Ticket
%small
= humanized_money_with_symbol @ticket.price
%p.text-muted
People who bought this ticket
.row