1 class CoitemController < ApplicationController
4 # Make sure that the user has logged in before they can take any
5 # action on checked out items
6 before_filter :authorize
9 render :action => 'index'
12 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 verify :method => :post, :only => [ :destroy, :create, :update ],
14 :redirect_to => { :action => :list }
17 @coitem_pages, @coitems = paginate :coitems, :per_page => 10
21 @coitem = Coitem.find(params[:id])
24 # We should never create new checked out items via the web interface, so remove
25 # the new and create methods.
28 @coitem = Coitem.find(params[:id])
32 @coitem = Coitem.find(params[:id])
33 if @coitem.update_attributes(params[:coitem])
34 flash[:notice] = 'Coitem was successfully updated.'
35 redirect_to :action => 'show', :id => @coitem
37 render :action => 'edit'
41 # We should never delete a checked out item directly via the web interface, so
42 # remove the destroy method.
44 # Awesome, paginating overdue list, ordered by customer
46 @coitem_pages, @coitems = paginate :coitems, :per_page => 50, :conditions => ["due_date < ?", Time.now.to_date], :order => "customer_id"
47 render :action => 'overdue'
52 rentable_id = params[:rentable_id]
53 @rentable = Rentable.find_by_id(rentable_id)
56 flash[:notice] = "Unable to find this rentable"
57 redirect_to :action => :return
61 @coitem = Coitem.find_by_rentable_id(rentable_id)
63 flash[:notice] = "This item is not checked out!"
64 redirect_to :action => :return
68 # Check if the item is overdue
70 @coitem.customer.debt += @coitem.late_fee
77 flash[:notice] = "Successfully returned item"
78 redirect_to :action => :return, :method => :get
80 render :action => 'return'