improve flash error collection

improve views
This commit is contained in:
Rishabh Saxena 2016-08-11 17:47:52 +05:30
parent 6bd2e5e335
commit 261d7dd0de
4 changed files with 15 additions and 19 deletions

View file

@ -23,6 +23,7 @@ class PaymentsController < ApplicationController
else else
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
flash[:error] = @payment.errors.full_messages.to_sentence + ' Please try again with correct credentials.'
render :new render :new
end end
end end

View file

@ -4,7 +4,7 @@ class TicketPurchasesController < ApplicationController
authorize_resource :conference_registrations, class: Registration authorize_resource :conference_registrations, class: Registration
def create def create
TicketPurchase.by_conference(@conference).unpaid.by_user(current_user).destroy_all current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank? if message.blank?
if current_user.ticket_purchases.by_conference(@conference).unpaid.any? if current_user.ticket_purchases.by_conference(@conference).unpaid.any?

View file

@ -85,12 +85,12 @@
- if @conference.tickets.any? - if @conference.tickets.any?
.row .row
.col-md-12 .col-md-12
%h4 -if @tickets.any?
%span.fa-stack %h4
%i.fa.fa-square-o.fa-stack-2x %span.fa-stack
%i.fa.fa-ticket.fa-stack-1x %i.fa.fa-square-o.fa-stack-2x
Ticket Purchases %i.fa.fa-ticket.fa-stack-1x
-if @tickets.any? Ticket Purchases
= "(#{@tickets.first.price.symbol}#{humanized_money @total_price})" = "(#{@tickets.first.price.symbol}#{humanized_money @total_price})"
%ul %ul
.col-md-12 .col-md-12
@ -103,13 +103,13 @@
= tickets.first.price.symbol = tickets.first.price.symbol
= humanized_money tickets.first.price = humanized_money tickets.first.price
%br %br
- if @tickets.any? - if @tickets.any?
= link_to 'Buy more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default" = link_to 'Buy more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default"
- else - else
You haven't bought any tickets. You haven't bought any tickets.
= link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title)
%p %p
(Your participation won't be valid without buying a ticket) (Your participation won't be valid without buying a ticket)
.row .row
.col-md-12 .col-md-12

View file

@ -4,11 +4,6 @@
%h1 %h1
Payment Summary : Payment Summary :
= humanized_money_with_symbol @total_amount_to_pay = humanized_money_with_symbol @total_amount_to_pay
- if @payment.errors.any?
.alert.alert-danger
%ul
- @payment.errors.full_messages.each do |msg|
%li= msg
.col-xs-8.col-xs-offset-2.well .col-xs-8.col-xs-offset-2.well
= render partial: 'payment' = render partial: 'payment'
.row .row