Prettify and add the Merchandise pages
authorIra W. Snyder <devel@irasnyder.com>
Mon, 26 Nov 2007 22:36:07 +0000 (14:36 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Mon, 26 Nov 2007 22:36:07 +0000 (14:36 -0800)
Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
app/controllers/merchandise_controller.rb
app/views/layouts/admin.rhtml
app/views/merchandise/index.rhtml [new file with mode: 0644]
app/views/merchandise/list.rhtml
app/views/merchandise/show.rhtml
db/development.sqlite3

index fb7beff..79a85dd 100644 (file)
@@ -1,11 +1,11 @@
 class MerchandiseController < ApplicationController
+  layout "admin"
 
   # Make sure that a user logs in before doing any action here
   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)
index 420c1ad..7a3e403 100644 (file)
@@ -18,6 +18,7 @@
       <br/>
       <p><%= link_to "Video Maintenence", :controller => 'video', :action => 'index' %></p>
       <p><%= link_to "Game Maintenence", :controller => 'game', :action => 'index' %></p>
+      <p><%= link_to "Merchandise Maintenence", :controller => 'merchandise', :action => 'index' %></p>
       <p><%= link_to "Checked Out Items", :controller => 'coitem', :action => 'index' %></p>
       <p><%= link_to "Customer Maintenence", :controller => 'customer', :action => 'index' %></p>
       <p><%= link_to "Financial Information", :controller => 'purchase', :action => 'index' %></p>
diff --git a/app/views/merchandise/index.rhtml b/app/views/merchandise/index.rhtml
new file mode 100644 (file)
index 0000000..ec31215
--- /dev/null
@@ -0,0 +1,7 @@
+<h1>Merchandise Maintenence</h1>
+
+<h3>Actions</h3>
+<ul>
+  <li><%= link_to 'List All Merchandise', :action => 'list' %></li>
+  <li><%= link_to 'Add a New Merchandise Item', :action => 'new' %></li>
+</ul>
index a328f09..91e8f5e 100644 (file)
@@ -1,22 +1,21 @@
 <h1>Listing merchandises</h1>
 
-<table>
+<table border="1">
   <tr>
-  <th>Merchandise ID</th>
-  <% for column in Merchandise.content_columns %>
-    <th><%= column.human_name %></th>
-  <% end %>
+    <th>Merchandise ID</th>
+    <th>Title</th>
+    <th>Quantity Remaining</th>
+    <th>Price Per Unit</th>
   </tr>
   
 <% for merchandise in @merchandises %>
   <tr>
-  <td><%=h merchandise.id %></td>
-  <% for column in Merchandise.content_columns %>
-    <td><%=h merchandise.send(column.name) %></td>
-  <% end %>
-    <td><%= link_to 'Show', :action => 'show', :id => merchandise %></td>
+    <td><%=h merchandise.id %></td>
+    <td><%=link_to merchandise.title.to_s, :action => 'show', :id => merchandise %></td>
+    <td><%=h merchandise.quantity %></td>
+    <td><%=h number_to_currency(merchandise.price) %></td>
     <td><%= link_to 'Edit', :action => 'edit', :id => merchandise %></td>
-    <td><%= link_to 'Destroy', { :action => 'destroy', :id => merchandise }, :confirm => 'Are you sure?', :method => :post %></td>
+    <td><%= link_to 'Remove', { :action => 'destroy', :id => merchandise }, :confirm => 'Are you sure?', :method => :post %></td>
   </tr>
 <% end %>
 </table>
index 9c90624..2180bfe 100644 (file)
@@ -1,8 +1,7 @@
-<% for column in Merchandise.content_columns %>
-<p>
-  <b><%= column.human_name %>:</b> <%=h @merchandise.send(column.name) %>
-</p>
-<% end %>
+<p><b>Merchandise ID: </b><%=h @merchandise.id.to_s %></p>
+<p><b>Title: </b><%=h @merchandise.title %></p>
+<p><b>Quantity Remaining: </b><%=h @merchandise.quantity %></p>
+<p><b>Price Per Unit: </b><%=h number_to_currency(@merchandise.price) %></p>
 
 <%= link_to 'Edit', :action => 'edit', :id => @merchandise %> |
 <%= link_to 'Back', :action => 'list' %>
index 7f6ff45..ce9e0e6 100644 (file)
Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ