Commit 518e52aac056e17dbf8cd1aa7eaf40f5ca88b590

Authored by MoisesMachado
1 parent a263c092

ActionItem140: made the infra for the advanced search


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1096 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/category_controller.rb
@@ -2,12 +2,11 @@ class CategoryController < ApplicationController @@ -2,12 +2,11 @@ class CategoryController < ApplicationController
2 2
3 before_filter :load_default_enviroment 3 before_filter :load_default_enviroment
4 4
5 -  
6 #FIXME This is not necessary because the application controller define the envrioment 5 #FIXME This is not necessary because the application controller define the envrioment
7 # as the default holder 6 # as the default holder
8 - 7 +
9 design :holder => 'environment' 8 design :holder => 'environment'
10 - 9 +
11 def load_default_enviroment 10 def load_default_enviroment
12 @environment = Environment.default 11 @environment = Environment.default
13 end 12 end
@@ -26,11 +25,12 @@ class CategoryController < ApplicationController @@ -26,11 +25,12 @@ class CategoryController < ApplicationController
26 send(@category.class.name.underscore.to_sym) 25 send(@category.class.name.underscore.to_sym)
27 # TODO: load articles, documents, etc so the view can list them. 26 # TODO: load articles, documents, etc so the view can list them.
28 end 27 end
29 - 28 +
30 protected 29 protected
31 def product_category 30 def product_category
32 @products = @category.all_products 31 @products = @category.all_products
33 @enterprises = Enterprise.find(:all, :conditions => ['products.id in (?)', @products.map(&:id)], :include => :products) 32 @enterprises = Enterprise.find(:all, :conditions => ['products.id in (?)', @products.map(&:id)], :include => :products)
  33 + @users = Profile.find(:all, :conditions => ['consumptions.product_category_id = (?)',@category.id], :include => :consumptions)
34 end 34 end
35 35
36 def category 36 def category
app/controllers/public/search_controller.rb
@@ -51,4 +51,8 @@ class SearchController < ApplicationController @@ -51,4 +51,8 @@ class SearchController < ApplicationController
51 @tagged = @tag.taggings.map(&:taggable) 51 @tagged = @tag.taggings.map(&:taggable)
52 end 52 end
53 53
  54 + def advanced_search
  55 +
  56 + end
  57 +
54 end 58 end
app/views/category/_product_category.rhtml
1 -<%= link_to(_('I consume this'), {:profile => current_user.login, :controller => 'consumed_products', :action => 'new', 'consumption[product_category_id]' => @category.id }, :method => :post) %> 1 +<%= link_to(_('I consume this'), {:profile => current_user.login, :controller => 'consumed_products', :action => 'new', 'consumption[product_category_id]' => @category.id }, :method => :post) if logged_in? %>
2 <ul> 2 <ul>
3 <li><%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %></li> 3 <li><%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %></li>
4 <li><%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %></li> 4 <li><%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %></li>
  5 + <li><%= n_("One user consumes this product.", "%{num} users consumes this product", @users.size) % {:num => @users.size} %></li>
5 </ul> 6 </ul>
6 7
  8 +<h3> <%= _('Products under this category:') %> </h3>
7 <ul> 9 <ul>
8 <% @products.each do |p| %> 10 <% @products.each do |p| %>
9 <li> 11 <li>
@@ -15,3 +17,12 @@ @@ -15,3 +17,12 @@
15 </li> 17 </li>
16 <% end %> 18 <% end %>
17 </ul> 19 </ul>
  20 +
  21 +<h3><%= _('Users that consumes products in this category:') %></h3>
  22 +
  23 +<% @users.each do |u| %>
  24 + <p>
  25 + <%= image_tag u.image.public_filename(:thumb) if u.image %> <br>
  26 + <%= link_to_homepage(u.name, u.identifier) %>
  27 + </p>
  28 +<% end %>
app/views/profile_editor/change_image.rhtml
1 -<% form_for :image, @image, :html => { :multipart => true }, :url => { :action => 'edit_image_preview'} do |f| %> 1 +<% form_for :image, @image, :html => { :multipart => true }, :url => { :action => 'change_image'} do |f| %>
2 <%= display_form_field(_('Image'), f.file_field( :uploaded_data ) ) %> 2 <%= display_form_field(_('Image'), f.file_field( :uploaded_data ) ) %>
3 <%= display_submit_tag(_('Upload')) %> 3 <%= display_submit_tag(_('Upload')) %>
4 <%= link_to _('Cancel'), :action => 'index' %> 4 <%= link_to _('Cancel'), :action => 'index' %>