From 92dc0edff28ab396f5f84a8e1a9b7f7ee590e03c Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Wed, 27 Jul 2016 19:38:57 +0530 Subject: [PATCH] modify registration view and controller --- .../conference_registrations_controller.rb | 6 ++- .../conference_registrations/show.html.haml | 40 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index 95e5c447..176f7937 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -28,8 +28,10 @@ class ConferenceRegistrationsController < ApplicationController end def show - @total_price = Ticket.total_price(@conference, current_user) - @tickets = current_user.ticket_purchases.where(conference_id: @conference.id) + @total_price = Ticket.total_price(@conference, current_user, paid: true) + @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 def edit; end diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index 30cb281b..24923d07 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -89,29 +89,27 @@ %span.fa-stack %i.fa.fa-square-o.fa-stack-2x %i.fa.fa-ticket.fa-stack-1x - Tickets + Ticket Purchases -if @tickets.any? - = "(#{@total_price} #{@tickets.first.price.symbol})" + = "(#{@tickets.first.price.symbol}#{humanized_money @total_price})" %ul - - @tickets.each do |ticket| - %li - = ticket.quantity - = ticket.title - = word_pluralize(ticket.quantity, 'Ticket') - for - = humanized_money ticket.price - = ticket.price.symbol - = link_to conference_ticket_purchase_path(@conference.short_title, ticket.id), method: :delete, - id: "ticket-#{ticket.id}-delete", - class: 'btn btn-danger btn-xs', - data: { confirm: "Do you really want to delete the #{ticket.title} ticket for #{@conference.title}?" } do - %i.fa.fa-trash-o - %li - - if @tickets.any? - = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title) - - else - You haven't bought any tickets. - = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) + .col-md-12 + - @ticket_payments.each_pair do |ticket_id, tickets| + %li + = @total_quantity[ticket_id] + = tickets.first.title + = word_pluralize(@total_quantity[ticket_id], 'Ticket') + for + = tickets.first.price.symbol + = humanized_money tickets.first.price + %br + - if @tickets.any? + = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default" + - else + You haven't bought any tickets. + = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) + %p + (Your registration won't be complete without buying a ticket) .row .col-md-12