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
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
@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
end
end

View file

@ -4,7 +4,7 @@ class TicketPurchasesController < ApplicationController
authorize_resource :conference_registrations, class: Registration
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])
if message.blank?
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?

View file

@ -85,12 +85,12 @@
- if @conference.tickets.any?
.row
.col-md-12
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-ticket.fa-stack-1x
Ticket Purchases
-if @tickets.any?
-if @tickets.any?
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-ticket.fa-stack-1x
Ticket Purchases
= "(#{@tickets.first.price.symbol}#{humanized_money @total_price})"
%ul
.col-md-12
@ -103,13 +103,13 @@
= 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 participation won't be valid without buying a ticket)
- 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 participation won't be valid without buying a ticket)
.row
.col-md-12

View file

@ -4,11 +4,6 @@
%h1
Payment Summary :
= 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
= render partial: 'payment'
.row