From: Ira W. Snyder Date: Sun, 25 Nov 2007 06:55:05 +0000 (-0800) Subject: Prettify the Game system X-Git-Tag: turned-in~37 X-Git-Url: https://www.irasnyder.com/gitweb/?a=commitdiff_plain;h=26ea4349c0583820be12b9f980ec4884f7db5690;p=cs356-p2-videostore.git Prettify the Game system Signed-off-by: Ira W. Snyder --- diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 31fe67e..c75ce07 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -1,11 +1,11 @@ class GameController < ApplicationController + layout "admin" # Make sure that the user has logged in before they can take any action before_filter :authorize def index - list - render :action => 'list' + render :action => 'index' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) @@ -53,12 +53,13 @@ class GameController < ApplicationController redirect_to :action => 'list' end - def searchbyname - render :action => 'searchbyname' - end - - def searchresults - query = params[:q] - @games = Game.find(:all, :conditions => ["title like ?", query[0]+"%"]) + def search + if request.post? + @query = params[:q] + @games = Game.find(:all, :conditions => ["title like ?", @query[0]+"%"]) + render :action => 'searchresults' + else + render :action => 'search' + end end end diff --git a/app/views/game/index.rhtml b/app/views/game/index.rhtml new file mode 100644 index 0000000..280522d --- /dev/null +++ b/app/views/game/index.rhtml @@ -0,0 +1,8 @@ +

Game Maintenence

+ +

Actions

+ diff --git a/app/views/game/list.rhtml b/app/views/game/list.rhtml index d35c1eb..123e767 100644 --- a/app/views/game/list.rhtml +++ b/app/views/game/list.rhtml @@ -1,26 +1,26 @@ -

Listing games

+

Listing Games

- +
- <% for game in @games %> - - + + - + - + <% end %>
Game ID Checked Out Title New Release GenrePlatform + Platform
<%=h game.id %><%=h game.checkedout? %> <%=h game.title %><%=h game.newrelease %><%=h tf_to_yesno(game.checkedout?) %><%=h tf_to_yesno(game.newrelease) %> <%=h game.genre %> <%=h game.game_platform %><%= link_to 'Show', :action => 'show', :id => game %><%= link_to 'View', :action => 'show', :id => game %> <%= link_to 'Edit', :action => 'edit', :id => game %><%= link_to 'Destroy', { :action => 'destroy', :id => game }, :confirm => 'Are you sure?', :method => :post %><%= link_to 'Remove', { :action => 'destroy', :id => game }, :confirm => 'Are you sure?', :method => :post %>
diff --git a/app/views/game/searchbyname.rhtml b/app/views/game/search.rhtml similarity index 56% rename from app/views/game/searchbyname.rhtml rename to app/views/game/search.rhtml index a5a4f8b..b4beb0f 100644 --- a/app/views/game/searchbyname.rhtml +++ b/app/views/game/search.rhtml @@ -1,7 +1,7 @@

Search for a Game by Name

-<%= start_form_tag :action => 'searchresults'%> -<%= text_field 'q', nil %> +<%= start_form_tag :action => 'search' %> +<%= text_field 'q', nil %> <%= submit_tag 'Search' %> <%= end_form_tag %> diff --git a/app/views/game/searchresults.rhtml b/app/views/game/searchresults.rhtml index 54e7998..203f4cc 100644 --- a/app/views/game/searchresults.rhtml +++ b/app/views/game/searchresults.rhtml @@ -1,27 +1,29 @@ -

Search Results

+

Search Results for '<%= @query[0].to_s %>'

<% if @games.empty? %>

Sorry, there were no results

<% else %> - +
- - - <% for column in Game.content_columns %> - - <% end %> + + + + + + <% for game in @games %> - - - <% for column in Game.content_columns %> - - <% end %> - + + + + + + + - + <% end %>
Game IDChecked Out<%= column.human_name %>Game IDChecked OutTitleNew ReleaseGenrePlatform
<%=h game.id %><%=h game.checkedout? %><%=h game.send(column.name) %><%= link_to 'Show', :action => 'show', :id => game %><%=h game.id %><%=h game.title %><%=h tf_to_yesno(game.checkedout?) %><%=h tf_to_yesno(game.newrelease) %><%=h game.genre %><%=h game.game_platform %><%= link_to 'View', :action => 'show', :id => game %> <%= link_to 'Edit', :action => 'edit', :id => game %><%= link_to 'Destroy', { :action => 'destroy', :id => game }, :confirm => 'Are you sure?', :post => true %><%= link_to 'Remove', { :action => 'destroy', :id => game }, :confirm => 'Are you sure?', :method => :post %>
diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index bb59815..d271822 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -17,7 +17,7 @@

<%= link_to "Return Items", :controller => 'coitem', :action => 'return' %>


<%= link_to "Video Maintenence", :controller => 'video', :action => 'index' %>

-

<%= link_to "Game Maintenence", :controller => 'game', :action => 'list' %>

+

<%= link_to "Game Maintenence", :controller => 'game', :action => 'index' %>

<%= link_to "Checked Out Items", :controller => 'coitem', :action => 'list' %>

<%= link_to "Customer Maintenence", :controller => 'customer', :action => 'list' %>