Changeset 1151
- Timestamp:
- 09/28/06 20:20:04 (2 years ago)
- Files:
-
- peasantonline/app/controllers/application.rb (modified) (1 diff)
- peasantonline/app/controllers/catalog_controller.rb (modified) (10 diffs)
- peasantonline/app/views/catalog/_left_nav.rhtml (modified) (1 diff)
- peasantonline/config/routes.rb (modified) (1 diff)
- peasantonline/public/stylesheets/catalog.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
peasantonline/app/controllers/application.rb
r1101 r1151 9 9 end 10 10 end 11 12 def prep_nav 13 @designers = Designer.find(:all, :order => "name") 14 @categories = Category.find(:all, :order => "name") 15 @cart = find_cart 16 end 11 17 end peasantonline/app/controllers/catalog_controller.rb
r1146 r1151 1 1 require 'payment' 2 2 class CatalogController < ApplicationController 3 before_filter :prep_nav 3 4 4 5 def sitemap 5 @designers = Designer.find(:all, :order => "name")6 @categories = Category.find(:all, :order => "name")7 6 end 8 7 9 8 def thanks 10 @designers = Designer.find(:all, :order => "name")11 @categories = Category.find(:all, :order => "name")12 9 end 13 10 14 11 def home 15 @designers = Designer.find(:all, :order => "name")16 @categories = Category.find(:all, :order => "name")17 12 @products = Product.find_tagged_with :all => 'featured', :limit => 2 18 @cart = find_cart19 13 end 20 14 … … 23 17 def browse_by_special 24 18 @special = humanize_param(params[:special]) 25 26 @designers = Designer.find(:all, :order => "name")27 @categories = Category.find(:all, :order => "name")28 19 @products = Product.find_tagged_with :all => @special 29 20 #@product_pages, @products = paginate(:products, :per_page => 9, :conditions => ["category = ?", @cat_obj.id]) 30 @cart = find_cart 21 31 22 end 32 23 … … 35 26 def browse_by_designer 36 27 @designer = humanize_param(params[:designer]) 28 if params[:gender] == "men" 29 gender_val = false 30 else 31 gender_val = true 32 end 37 33 38 34 @des_obj = Designer.find_by_name(@designer) 39 35 #@products = Product.find_all_by_designer(@des_obj.id) 40 @product_pages, @products = paginate(:products, :per_page => 9, :conditions => ["designer = ?", @des_obj.id]) 41 @designers = Designer.find(:all, :order => "name") 42 @categories = Category.find(:all, :order => "name") 43 @cart = find_cart 36 @product_pages, @products = paginate(:products, :per_page => 9, :conditions => "designer = '#{@des_obj.id}' and gender = #{gender_val}") 37 44 38 end 45 39 … … 48 42 def browse_by_category 49 43 @category = humanize_param(params[:category]) 44 if params[:gender] == "men" 45 gender_val = false 46 else 47 gender_val = true 48 end 50 49 51 50 @cat_obj = Category.find_by_name(@category) 52 51 #@products = Product.find_all_by_category(@cat_obj.id) 53 @product_pages, @products = paginate(:products, :per_page => 9, :conditions => ["category = ?", @cat_obj.id]) 54 @designers = Designer.find(:all, :order => "name") 55 @categories = Category.find(:all, :order => "name") 56 @cart = find_cart 52 @product_pages, @products = paginate(:products, :per_page => 9, :conditions => "category = '#{@cat_obj.id}' and gender = #{gender_val}") 57 53 end 58 54 … … 64 60 gender_val = true 65 61 end 66 67 #Product.find(:all, :conditions => ["gender = ?", gender_val])68 #@products = Product.find_all_by_gender(gender_val)69 62 @product_pages, @products = paginate(:products, :per_page => 9, :conditions => ["gender = ?", gender_val]) 70 63 71 @designers = Designer.find(:all, :order => "name")72 @categories = Category.find(:all, :order => "name")73 @cart = find_cart74 64 end 75 65 76 66 def browse_by_product 77 67 @product = Product.find(params[:product]) 78 @designers = Designer.find(:all, :order => "name") 79 @categories = Category.find(:all, :order => "name") 80 68 81 69 # Product detail object 82 70 ProductDetail.find(:all, :conditions => ["product = ?", params[:product]]) … … 86 74 ProductImage.find(:all, :conditions => ["product = ?", params[:product]]) 87 75 @product_images = ProductImage.find_all_by_product(params[:product]) 88 @cart = find_cart89 76 end 90 77 … … 102 89 redirect_to_index("Invalid size") 103 90 else 104 @cart = find_cart105 91 @current_item = @cart.add_product(@product, @product_detail.size) 106 92 @product_details = ProductDetail.find_all_by_product(params[:id]) … … 117 103 # to be defined; not sure if these two belong in the catalog controller... 118 104 def checkout 119 @cart = find_cart120 105 end 121 106 122 107 def view_cart 123 @cart = find_cart124 108 end 125 109 … … 131 115 132 116 @order = Order.new 133 @designers = Designer.find(:all, :order => "name")134 @categories = Category.find(:all, :order => "name")135 117 end 136 118 end 137 119 138 120 def save_order 139 @cart = find_cart140 121 @order = Order.new(params[:order]) 141 122 @order.add_line_items_from_cart(@cart) … … 146 127 end 147 128 148 @designers = Designer.find(:all, :order => "name")149 @categories = Category.find(:all, :order => "name")150 129 151 130 if @order.save peasantonline/app/views/catalog/_left_nav.rhtml
r1128 r1151 6 6 </div> 7 7 <% end %> 8 <% gender_list = ['men','women']%> 9 <% for gender in gender_list %> 10 <div class="gender_block"> 11 <div class="subhead"><a href="<%= shop_by_gender_url(:gender => gender ) %>"><%= gender.capitalize %>'s items</a></div> 12 <%if params[:gender] == gender || !params[:gender] %> 13 <% if @designers %> 14 <select onchange="if( this.selectedIndex != 0 ) {location.href = this.options[this.selectedIndex].value;}"> 15 <option value=""> Select a Designer: </option> 16 <% for designer in @designers %> 17 <option value="<%= shop_by_designer_url(:gender=>gender, :designer => make_linkable( designer.name )) %>"> 18 <%= canonicalize_designer( designer.name ) %> 19 </option> 20 <% end %> 21 </select> 22 <% end %> 8 23 9 <span class="subhead">Shop by</span> 10 <ul> 11 <li><a href="<%= shop_by_gender_url(:gender => "men" ) %>">Men's items</a></li> 12 <li><a href="<%= shop_by_gender_url(:gender => "women" ) %>">Women's items</a></li> 13 </ul> 14 15 <% if @categories %> 16 <span class="subhead">Categories</span> 17 <ul> 18 <% for category in @categories %> 19 <li><a href="<%= shop_by_category_url(:category => make_linkable( category.name )) %>"><%= category.name.capitalize %></a></li> 20 <% end %> 24 <% if @categories %> 25 <ul> 26 <% for category in @categories %> 27 <li><a href="<%= shop_by_category_url(:gender => gender,:category => make_linkable( category.name )) %>"><%= category.name.capitalize %></a></li> 28 <% end %> 21 29 </ul> 22 30 <% end %> 23 24 <% if @designers %>25 <span class="subhead">Designers</span>26 <select onchange="if( this.selectedIndex != 0 ) {location.href = this.options[this.selectedIndex].value;}">27 <option value=""> Select: </option>28 <% for designer in @designers %>29 <option value="<%= shop_by_designer_url(:designer => make_linkable( designer.name )) %>">30 <%= canonicalize_designer( designer.name ) %>31 </option>32 31 <% end %> 33 </select>32 </div> 34 33 <% end %> 35 34 35 36 36 <p /> 37 37 peasantonline/config/routes.rb
r1135 r1151 22 22 map.shop_by_product 'shop/product/:product', :controller => "catalog", :action => "browse_by_product" 23 23 map.shop_by_special 'shop/specials/:special', :controller => "catalog", :action => "browse_by_special" 24 map.shop_by_designer 'shop/designers/:designer', :controller => "catalog", :action => "browse_by_designer" 25 map.shop_by_category 'shop/categories/:category', :controller => "catalog", :action => "browse_by_category" 26 map.shop_by_gender 'shop/:gender', :controller => 'catalog', :action => 'browse_by_gender', 27 :requirements => {:gender => /men|women|mens|womens/} 24 map.shop_by_designer 'shop/designers/:gender/:designer', :controller => "catalog", :action => "browse_by_designer", :requirements => {:gender => /men|women/} 25 map.shop_by_category 'shop/categories/:gender/:category', :controller => "catalog", :action => "browse_by_category", :requirements => {:gender => /men|women/} 26 map.shop_by_gender 'shop/:gender', :controller => 'catalog', :action => 'browse_by_gender',:requirements => {:gender => /men|women/} 28 27 29 28 # Allow downloading Web Service WSDL as a file with an extension peasantonline/public/stylesheets/catalog.css
r1150 r1151 203 203 204 204 } 205 206 select { 207 font-family: courier; 208 font-size: 10px; 209 color: #333333; 210 } 211 .gender_block { 212 margin-bottom: 15px; 213 214 }