Added date_available_from to products, updated conditions in product.find_products_fo...
[depot.git] / app / views / products / index.html.erb
1 <div id="product-list">
2 <h1>Listing products</h1>
3
4 <table>
5 <% for product in @products %>
6 <tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
7 <td>
8 <%= image_tag product.image_url, :class => 'list-image' %>
9 </td>
10 <td class="list-description">
11 <dl>
12 <dt><%=h product.title %></dt>
13 <dd><%=h truncate(product.description.gsub(/<.*?>/, '|'),
14 :length => 80) %></dd>
15 <dd><%=number_to_currency product.price, :unit => "£" %>
16 <% if product.date_available.past? %>
17 <dd>Available since <%= product.date_available %></dd>
18 <% else %>
19 <dd class="unavailable">Available from <%= product.date_available %></dd>
20 <% end %>
21 <% if not product.date_available_until.nil? %>
22 <% if product.date_available_until.future? %>
23 <dd>Available until <%= product.date_available_until %></dd>
24 <% else %>
25 <dd class="unavailable">Unavailable since <%= product.date_available_until %></dd>
26 <% end %>
27 <% end %>
28 </dl>
29 </td>
30
31 <td class="list-actions">
32 <%= link_to 'Show', product %><br/>
33 <%= link_to 'Edit', edit_product_path(product) %><br/>
34 <%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %><br/>
35 </td>
36 </tr>
37 <% end %>
38 </table>
39 </div>
40 <br />
41 <%= link_to 'New product', new_product_path %>