Commit 128fa31d authored by Leandro Nunes's avatar Leandro Nunes

removing profile_cat_icons

parent 13870552
......@@ -503,32 +503,6 @@ module ApplicationHelper
sex
end
def profile_cat_icons( profile )
if profile.class == Enterprise
icons = profile.product_categories.unique_by_level(2).limit(3).map do |c|
filtered_category = c.filtered_category.blank? ? c.path.split('/').last : c.filtered_category
category_title = filtered_category.split(/[-_\s,.;'"]+/).map(&:capitalize).join(' ')
category_name = category_title.gsub(' ', '_' )
category_icon = "/images/icons-cat/#{category_name}.png"
if ! File.exists?(Rails.root.join('public', category_icon))
category_icon = '/images/icons-cat/undefined.png'
end
content_tag('span',
content_tag( 'span', category_title ),
:title => category_title,
:class => 'product-cat-icon cat_icon_' + category_name,
:style => "background-image:url(#{category_icon})"
)
end.join("\n").html_safe
content_tag('div',
content_tag( 'span', _('Principal Product Categories'), :class => 'header' ) +"\n"+ icons,
:class => 'product-category-icons'
)
else
''
end
end
def links_for_balloon(profile)
if environment.enabled?(:show_balloon_with_profile_links_when_clicked)
if profile.kind_of?(Person)
......@@ -587,7 +561,7 @@ module ApplicationHelper
link_to(
content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) +
content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) +
extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ),
extra_info + profile_sex_icon( profile ),
profile.url,
:class => 'profile_link url',
:help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name,
......
......@@ -13,9 +13,6 @@ class ProductCategory < Category
scope :by_environment, -> environment {
where 'environment_id = ?', environment.id
}
scope :unique_by_level, -> level {
select "DISTINCT ON (filtered_category) split_part(path, '/', #{level}) AS filtered_category, categories.*"
}
def all_products
Product.where(product_category_id: (all_children << self).map(&:id))
......
......@@ -7,8 +7,7 @@
<span class="profile-info-picture-inner2">
<%=
profile_image(block.owner, :thumb) +"\n"+
profile_sex_icon( profile ) +
profile_cat_icons( profile )
profile_sex_icon( profile )
%>
</span>
</div>
......
......@@ -85,14 +85,4 @@ class ProductCategoryTest < ActiveSupport::TestCase
assert_equivalent [c1,c3], ProductCategory.by_environment(Environment.default)
end
should 'fetch unique categories by level' do
c1 = ProductCategory.create!(:name => 'test cat 1', :environment => Environment.default)
c11 = ProductCategory.create!(:name => 'test cat 11', :environment => Environment.default, :parent => c1)
c12 = ProductCategory.create!(:name => 'test cat 12', :environment => Environment.default, :parent => c1)
c111 = ProductCategory.create!(:name => 'test cat 111', :environment => Environment.default, :parent => c11)
c112 = ProductCategory.create!(:name => 'test cat 112', :environment => Environment.default, :parent => c11)
assert_equivalent ['', 'test-cat-11', 'test-cat-12'], ProductCategory.unique_by_level(2).map(&:filtered_category)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment