modify registration view and controller

This commit is contained in:
Rishabh Saxena 2016-07-27 19:38:57 +05:30
parent 8f39fc83d2
commit 92dc0edff2
2 changed files with 23 additions and 23 deletions

View file

@ -28,8 +28,10 @@ class ConferenceRegistrationsController < ApplicationController
end end
def show def show
@total_price = Ticket.total_price(@conference, current_user) @total_price = Ticket.total_price(@conference, current_user, paid: true)
@tickets = current_user.ticket_purchases.where(conference_id: @conference.id) @tickets = current_user.ticket_purchases.by_conference(@conference).paid
@ticket_payments = @tickets.group_by(&:ticket_id)
@total_quantity = @tickets.group(:ticket_id).sum(:quantity)
end end
def edit; end def edit; end

View file

@ -89,29 +89,27 @@
%span.fa-stack %span.fa-stack
%i.fa.fa-square-o.fa-stack-2x %i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-ticket.fa-stack-1x %i.fa.fa-ticket.fa-stack-1x
Tickets Ticket Purchases
-if @tickets.any? -if @tickets.any?
= "(#{@total_price} #{@tickets.first.price.symbol})" = "(#{@tickets.first.price.symbol}#{humanized_money @total_price})"
%ul %ul
- @tickets.each do |ticket| .col-md-12
%li - @ticket_payments.each_pair do |ticket_id, tickets|
= ticket.quantity %li
= ticket.title = @total_quantity[ticket_id]
= word_pluralize(ticket.quantity, 'Ticket') = tickets.first.title
for = word_pluralize(@total_quantity[ticket_id], 'Ticket')
= humanized_money ticket.price for
= ticket.price.symbol = tickets.first.price.symbol
= link_to conference_ticket_purchase_path(@conference.short_title, ticket.id), method: :delete, = humanized_money tickets.first.price
id: "ticket-#{ticket.id}-delete", %br
class: 'btn btn-danger btn-xs', - if @tickets.any?
data: { confirm: "Do you really want to delete the #{ticket.title} ticket for #{@conference.title}?" } do = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default"
%i.fa.fa-trash-o - else
%li You haven't bought any tickets.
- if @tickets.any? = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title)
= link_to 'Buy more tickets', conference_tickets_path(@conference.short_title) %p
- else (Your registration won't be complete without buying a ticket)
You haven't bought any tickets.
= link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title)
.row .row
.col-md-12 .col-md-12