diff --git a/app/controllers/public/category_controller.rb b/app/controllers/public/category_controller.rb index 87f1158..7126539 100644 --- a/app/controllers/public/category_controller.rb +++ b/app/controllers/public/category_controller.rb @@ -2,14 +2,26 @@ class CategoryController < PublicController # view the summary of one category def view - # TODO: load articles, documents, etc so the view can list them. - @recent_articles = category.recent_articles - @recent_comments = category.recent_comments - @most_commented_articles = category.most_commented_articles + send('action_' + @category.class.name.underscore) end attr_reader :category before_filter :load_category, :only => [ :view ] + private + + def action_product_category + @products = category.products + @enterprises = category.products.map{|p| p.enterprise}.flatten.uniq + @users = category.consumers + end + + def action_category + # TODO: load articles, documents, etc so the view can list them. + @recent_articles = category.recent_articles + @recent_comments = category.recent_comments + @most_commented_articles = category.most_commented_articles + end + alias :action_region :action_category end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bf9257e..f57d9e7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -306,9 +306,10 @@ module ApplicationHelper concat(content_tag('div', capture(&block) + tag('br', :style => 'clear: left;'), { :class => 'button-bar' }.merge(options)), block.binding) end - def link_to_category(category) + def link_to_category(category, full = true) return _('Uncategorized product') unless category - link_to category.full_name, :controller => 'category', :action => 'view', :category_path => category.path.split('/') + name = full ? category.full_name : category.name + link_to name, :controller => 'category', :action => 'view', :category_path => category.path.split('/') end def link_to_product(product) diff --git a/app/models/product_category.rb b/app/models/product_category.rb index ec4240d..ce91b4f 100644 --- a/app/models/product_category.rb +++ b/app/models/product_category.rb @@ -1,7 +1,7 @@ class ProductCategory < Category has_many :products has_many :consumptions - has_many :consumers, :through => :consumptions, :source => :profile_id + has_many :consumers, :through => :consumptions, :source => :profile def tree children.inject([]){|all,c| all + c.tree } << self diff --git a/app/views/category/_product_category.rhtml b/app/views/category/_product_category.rhtml index 01dc200..1d9d887 100644 --- a/app/views/category/_product_category.rhtml +++ b/app/views/category/_product_category.rhtml @@ -9,7 +9,8 @@