X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=app%2Fcontrollers%2Fpurchase_controller.rb;fp=app%2Fcontrollers%2Fpurchase_controller.rb;h=a3b61bb61739248ddfb99d26fba87fe5c9a49e86;hb=9218748c58d552432e7bd4a34383589eb17ac331;hp=704e38b78b0e03737cbcb732b15bae02096df0ff;hpb=9b264f25255cc0e7cca3169d99905f590c8be578;p=cs356-p2-videostore.git diff --git a/app/controllers/purchase_controller.rb b/app/controllers/purchase_controller.rb index 704e38b..a3b61bb 100644 --- a/app/controllers/purchase_controller.rb +++ b/app/controllers/purchase_controller.rb @@ -58,6 +58,21 @@ class PurchaseController < ApplicationController return end + # Check Rentable Policies + @maxvideos = RentablePolicy.find_by_name("MaxVideos") + if @rentable.class == Video and @customer.checked_out_videos >= @maxvideos.value + flash[:error] = "#{@maxvideos.description} LIMIT REACHED" + redirect_to :action => :rent_begin + return + end + + @maxgames = RentablePolicy.find_by_name("MaxGames") + if @rentable.class == Game and @customer.checked_out_games >= @maxgames.value + flash[:error] = "#{@maxgames.description} LIMIT REACHED" + redirect_to :action => :rent_begin + return + end + # Check out the item checkout = Coitem.new checkout.customer = @customer