From: Ira W. Snyder <devel@irasnyder.com> Date: Mon, 26 Nov 2007 07:53:21 +0000 (-0800) Subject: Many visual tweaks, suggested by Lan X-Git-Tag: turned-in~28 X-Git-Url: https://www.irasnyder.com/gitweb/?a=commitdiff_plain;h=e4597521e3a7365f86731f7d69643cb1067acb5e;p=cs356-p2-videostore.git Many visual tweaks, suggested by Lan Signed-off-by: Ira W. Snyder <devel@irasnyder.com> --- diff --git a/app/controllers/coitem_controller.rb b/app/controllers/coitem_controller.rb index ef8ea7c..152f40b 100644 --- a/app/controllers/coitem_controller.rb +++ b/app/controllers/coitem_controller.rb @@ -47,6 +47,12 @@ class CoitemController < ApplicationController render :action => 'overdue' end + def filterbycustomerid + query = params[:id] + @coitem_pages, @coitems = paginate :coitems, :per_page => 20, :conditions => ["customer_id = ?", query] + render :action => 'list' + end + def return if request.post? rentable_id = params[:rentable_id] diff --git a/app/models/game.rb b/app/models/game.rb index ed7f30b..f2e627c 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,4 +1,7 @@ class Game < Rentable + has_many :game_genres, :through => Gamegenre + has_many :gameplatforms, :through => Gameplatform + validates_presence_of :game_genre validates_presence_of :platform @@ -32,4 +35,12 @@ class Game < Rentable return Time.now.advance(:days => period).to_date end + def genre_name + Gamegenre.find_by_id(game_genre).name + end + + def platform_name + Gameplatform.find_by_id(platform).name + end + end diff --git a/app/models/gamegenre.rb b/app/models/gamegenre.rb index 5a6631a..37c1eff 100644 --- a/app/models/gamegenre.rb +++ b/app/models/gamegenre.rb @@ -1,2 +1,3 @@ class Gamegenre < ActiveRecord::Base + belongs_to :game end diff --git a/app/models/gameplatform.rb b/app/models/gameplatform.rb index 340470f..c14fcf7 100644 --- a/app/models/gameplatform.rb +++ b/app/models/gameplatform.rb @@ -1,2 +1,3 @@ class Gameplatform < ActiveRecord::Base + belongs_to :game end diff --git a/app/views/coitem/list.rhtml b/app/views/coitem/list.rhtml index 2b0db69..92113ad 100644 --- a/app/views/coitem/list.rhtml +++ b/app/views/coitem/list.rhtml @@ -2,7 +2,9 @@ <table border="1"> <tr> + <th>Item ID</th> <th>Customer</th> + <th>Type</th> <th>Rentable</th> <th>Overdue</th> <th>Date Checked Out</th> @@ -11,12 +13,17 @@ <% for coitem in @coitems %> <tr> + <td><%=h coitem.rentable.id.to_s %></td> <td><%=h coitem.customer.name %></td> - <td><%=h coitem.rentable.title %></td> + <td><%=h coitem.rentable.class %></td> + <% if coitem.rentable.type == Game %> + <td><%=link_to coitem.rentable.title.to_s, :controller => 'game', :action => 'show', :id => coitem.rentable %></td> + <% else %> + <td><%=link_to coitem.rentable.title.to_s, :controller => 'video', :action => 'show', :id => coitem.rentable %></td> + <% end %> <td><%=h tf_to_yesno(coitem.overdue?) %></td> <td><%=h coitem.out_date %></td> <td><%=h coitem.due_date %></td> - <td><%= link_to 'View', :action => 'show', :id => coitem %></td> </tr> <% end %> </table> diff --git a/app/views/coitem/overdue.rhtml b/app/views/coitem/overdue.rhtml index d6f525e..ab44d10 100644 --- a/app/views/coitem/overdue.rhtml +++ b/app/views/coitem/overdue.rhtml @@ -2,6 +2,7 @@ <table border="1"> <tr> + <th>Item ID</th> <th>Customer</th> <th>Customer Phone #</th> <th>Customer Email</th> @@ -14,6 +15,7 @@ <% for coitem in @coitems %> <tr> + <td><%=h coitem.rentable.id.to_s %></td> <td><%=link_to coitem.customer.name, :controller => 'customer', :action => 'show', :id => coitem.customer.id %></td> <td><%=h coitem.customer.phone %></td> <td><%=h coitem.customer.email %></td> diff --git a/app/views/customer/list.rhtml b/app/views/customer/list.rhtml index c9bce2b..2f4bd9c 100644 --- a/app/views/customer/list.rhtml +++ b/app/views/customer/list.rhtml @@ -2,19 +2,19 @@ <table border="1"> <tr> - <th>Customer ID</th> - <% for column in Customer.content_columns %> - <th><%= column.human_name %></th> - <% end %> + <th>Customer ID</th> + <th>Name</th> + <th>Phone</th> + <th>Debt</th> </tr> <% for customer in @customers %> <tr> - <td><%=h customer.id %></td> - <% for column in Customer.content_columns %> - <td><%=h customer.send(column.name) %></td> - <% end %> - <td><%= link_to 'View', :action => 'show', :id => customer %></td> + <td><%=h customer.id %></td> + <td><%=link_to customer.name.to_s, :action => 'show', :id => customer %></td> + <td><%=h customer.phone %></td> + <td><%=h number_to_currency(customer.debt) %></td> + <td><%= link_to "Checked Out Items", :controller => :coitem, :action => 'filterbycustomerid', :id => customer %></td> <td><%= link_to 'Edit', :action => 'edit', :id => customer %></td> <td><%= link_to 'Remove', { :action => 'destroy', :id => customer }, :confirm => 'Are you sure?', :method => :post %></td> </tr> diff --git a/app/views/game/show.rhtml b/app/views/game/show.rhtml index b3c282f..e31791b 100644 --- a/app/views/game/show.rhtml +++ b/app/views/game/show.rhtml @@ -1,8 +1,9 @@ -<% for column in Game.content_columns %> -<p> - <b><%= column.human_name %>:</b> <%=h @game.send(column.name) %> -</p> -<% end %> +<p><b>Game ID:</b> <%=h @game.id.to_s %></p> +<p><b>Title:</b> <%=h @game.title %></p> +<p><b>New Release:</b> <%=h tf_to_yesno(@game.newrelease) %></p> +<p><b>Genre:</b> <%=h @game.genre_name %></p> +<p><b>Platform:</b> <%=h @game.platform_name %></p> + <%= link_to 'Edit', :action => 'edit', :id => @game %> | <%= link_to 'Back', :action => 'list' %> diff --git a/app/views/game_policy/list.rhtml b/app/views/game_policy/list.rhtml index 03b7b37..327c35d 100644 --- a/app/views/game_policy/list.rhtml +++ b/app/views/game_policy/list.rhtml @@ -1,17 +1,17 @@ -<h1>Game Rental Policies</h1> +<h1>Game Rental Pricing and Policies</h1> <table border="1"> <tr> - <% for column in GamePolicy.content_columns %> - <th><%= column.human_name %></th> - <% end %> + <th>Description</th> + <th>Fee</th> + <th>Period</th> </tr> <% for game_policy in @game_policies %> <tr> - <% for column in GamePolicy.content_columns %> - <td><%=h game_policy.send(column.name) %></td> - <% end %> + <td><%=h game_policy.description %></td> + <td><%=h number_to_currency(game_policy.fee) %></td> + <td><%=h game_policy.period %> Days</td> <td><%= link_to 'View', :action => 'show', :id => game_policy %></td> <td><%= link_to 'Edit', :action => 'edit', :id => game_policy %></td> </tr> @@ -21,6 +21,3 @@ <%= link_to 'Previous page', { :page => @game_policy_pages.current.previous } if @game_policy_pages.current.previous %> <%= link_to 'Next page', { :page => @game_policy_pages.current.next } if @game_policy_pages.current.next %> -<br /> - -<%= link_to 'New game_policy', :action => 'new' %> diff --git a/app/views/purchase/list.rhtml b/app/views/purchase/list.rhtml index 4c6e1ec..b702f7f 100644 --- a/app/views/purchase/list.rhtml +++ b/app/views/purchase/list.rhtml @@ -14,7 +14,7 @@ <tr> <td><%=link_to purchase.date, :action => 'filterbydate', :id => purchase.date %></td> <td><%=h purchase.quantity %></td> - <td><%=link_to purchase.type, :action => 'filterbytype', :id => purchase.type %></td> + <td><%=link_to purchase.class, :action => 'filterbytype', :id => purchase.type %></td> <td><%=h purchase.title %></td> <td><%=h purchase.price %></td> <td><%=link_to purchase.customer.name, :action => 'filterbycust', :id => purchase.customer_id %></td> diff --git a/app/views/video/show.rhtml b/app/views/video/show.rhtml index d7d089d..631ec4b 100644 --- a/app/views/video/show.rhtml +++ b/app/views/video/show.rhtml @@ -1,8 +1,9 @@ -<% for column in Video.content_columns %> -<p> - <b><%= column.human_name %>:</b> <%=h @video.send(column.name) %> -</p> -<% end %> +<p><b>Video ID:</b> <%=h @video.id.to_s %></p> +<p><b>Title:</b> <%=h @video.title %></p> +<p><b>New Release:</b> <%=h tf_to_yesno(@video.newrelease) %></p> +<p><b>Genre:</b> <%=h @video.genre %></p> +<p><b>Director:</b> <%=h @video.director %></p> +<p><b>Media:</b> <%=h @video.media_name %></p> <%= link_to 'Edit', :action => 'edit', :id => @video %> | <%= link_to 'Back', :action => 'list' %> diff --git a/app/views/video_policy/list.rhtml b/app/views/video_policy/list.rhtml index 0573275..3a04b33 100644 --- a/app/views/video_policy/list.rhtml +++ b/app/views/video_policy/list.rhtml @@ -1,17 +1,17 @@ -<h1>Video Rental Policies</h1> +<h1>Video Rental Pricing and Policies</h1> <table border="1"> <tr> - <% for column in VideoPolicy.content_columns %> - <th><%= column.human_name %></th> - <% end %> + <th>Description</th> + <th>Fee</th> + <th>Period</th> </tr> <% for video_policy in @video_policies %> <tr> - <% for column in VideoPolicy.content_columns %> - <td><%=h video_policy.send(column.name) %></td> - <% end %> + <td><%=h video_policy.description %></td> + <td><%=h number_to_currency(video_policy.fee) %></td> + <td><%=h video_policy.period %>Days</td> <td><%= link_to 'View', :action => 'show', :id => video_policy %></td> <td><%= link_to 'Edit', :action => 'edit', :id => video_policy %></td> </tr> @@ -21,6 +21,3 @@ <%= link_to 'Previous page', { :page => @video_policy_pages.current.previous } if @video_policy_pages.current.previous %> <%= link_to 'Next page', { :page => @video_policy_pages.current.next } if @video_policy_pages.current.next %> -<br /> - -<%= link_to 'New video_policy', :action => 'new' %> diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 86d8540..f826509 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ