diff --git a/app/assets/javascripts/osem-tickets.js b/app/assets/javascripts/osem-tickets.js index 51926a3f..ea99a349 100644 --- a/app/assets/javascripts/osem-tickets.js +++ b/app/assets/javascripts/osem-tickets.js @@ -22,4 +22,7 @@ $( document ).ready(function() { $('.quantity').change(function() { update_price($(this)); }); + $(function () { + $('[data-toggle="tooltip"]').tooltip() + }); }); diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 08806b95..54f5c3d7 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -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 diff --git a/app/views/admin/tickets/index.html.haml b/app/views/admin/tickets/index.html.haml index acf6915f..2a2bac6d 100644 --- a/app/views/admin/tickets/index.html.haml +++ b/app/views/admin/tickets/index.html.haml @@ -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), diff --git a/app/views/admin/tickets/show.html.haml b/app/views/admin/tickets/show.html.haml index f92b03b6..a672ff2c 100644 --- a/app/views/admin/tickets/show.html.haml +++ b/app/views/admin/tickets/show.html.haml @@ -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