class PurchaseController < ApplicationController
+ # Make sure that a user logs in before doing any action here
+ before_filter :authorize
+
def index
redirect_to :action => :begin
end
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