Merge 4ce142d0e3 into 952e8ac316
This commit is contained in:
commit
225d82a6b7
2 changed files with 7 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class PaymentsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
load_and_authorize_resource
|
||||
load_and_authorize_resource except: :new
|
||||
load_resource :conference, find_by: :short_title
|
||||
authorize_resource :conference_registrations, class: Registration
|
||||
|
||||
|
|
@ -9,6 +9,7 @@ class PaymentsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
authorize! :new, Payment.new(conference_id: @conference.id)
|
||||
@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)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ class Ability
|
|||
can :index, Ticket
|
||||
can :manage, TicketPurchase, user_id: user.id
|
||||
can [:new, :create], Payment, user_id: user.id
|
||||
|
||||
can :new, Payment do |payment|
|
||||
payment.conference.end_date >= Date.today
|
||||
end
|
||||
|
||||
can [:index, :show], PhysicalTicket, user: user
|
||||
|
||||
can [:new, :create], Booth do |booth|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue