X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fcontrollers%2Fpurchase_controller.rb;fp=app%2Fcontrollers%2Fpurchase_controller.rb;h=ebb08cd93dda1c00ac244534bb447c42805394d9;hb=93daca12cd904df11a8faadda08e487e9a4de8b7;hp=a3b61bb61739248ddfb99d26fba87fe5c9a49e86;hpb=9218748c58d552432e7bd4a34383589eb17ac331;p=cs356-p2-videostore.git diff --git a/app/controllers/purchase_controller.rb b/app/controllers/purchase_controller.rb index a3b61bb..ebb08cd 100644 --- a/app/controllers/purchase_controller.rb +++ b/app/controllers/purchase_controller.rb @@ -73,6 +73,20 @@ class PurchaseController < ApplicationController return end + @maxoverduevideos = RentablePolicy.find_by_name("MaxOverdueVideos") + if @rentable.class == Video and @customer.overdue_videos >= @maxoverduevideos.value + flash[:error] = "#{@maxoverduevideos.description} LIMIT REACHED" + redirect_to :action => :rent_begin + return + end + + @maxoverduegames = RentablePolicy.find_by_name("MaxOverdueGames") + if @rentable.class == Game and @customer.overdue_games >= @maxoverduegames.value + flash[:error] = "#{@maxoverduegames.description} LIMIT REACHED" + redirect_to :action => :rent_begin + return + end + # Check out the item checkout = Coitem.new checkout.customer = @customer