mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Added amount check for payments#new
This commit is contained in:
parent
72afae6f2f
commit
3b27a2a8fb
1 changed files with 3 additions and 6 deletions
|
|
@ -3,7 +3,6 @@ class PaymentsController < ApplicationController
|
|||
load_and_authorize_resource
|
||||
load_resource :conference, find_by: :short_title
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
before_action :check_amount, only: [:new]
|
||||
|
||||
def index
|
||||
@payments = current_user.payments
|
||||
|
|
@ -11,6 +10,9 @@ class PaymentsController < ApplicationController
|
|||
|
||||
def new
|
||||
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
|
||||
if @total_amount_to_pay.zero?
|
||||
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)
|
||||
end
|
||||
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
|
||||
end
|
||||
|
||||
|
|
@ -29,11 +31,6 @@ class PaymentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def check_amount
|
||||
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
|
||||
redirect_to root_path if @total_amount_to_pay.zero?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def payment_params
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue