[Git][noosfero/noosfero][master] 2 commits: removing profile_cat_icons
Leandro Nunes
gitlab at mg.gitlab.com
Mon Dec 28 15:04:06 BRST 2015
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
128fa31d by Leandro Nunes dos Santos at 2015-12-09T08:43:14Z
removing profile_cat_icons
- - - - -
0726343b by Leandro Nunes at 2015-12-28T17:03:50Z
Merge branch 'remove_profile_cat_icons' into 'master'
removing category icons from enterprise list
remove some specific code that display category icons on enterprise images
See merge request !744
- - - - -
4 changed files:
- app/helpers/application_helper.rb
- app/models/product_category.rb
- app/views/blocks/profile_info.html.erb
- test/unit/product_category_test.rb
Changes:
=====================================
app/helpers/application_helper.rb
=====================================
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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,
=====================================
app/models/product_category.rb
=====================================
--- a/app/models/product_category.rb
+++ b/app/models/product_category.rb
@@ -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))
=====================================
app/views/blocks/profile_info.html.erb
=====================================
--- a/app/views/blocks/profile_info.html.erb
+++ b/app/views/blocks/profile_info.html.erb
@@ -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>
=====================================
test/unit/product_category_test.rb
=====================================
--- a/test/unit/product_category_test.rb
+++ b/test/unit/product_category_test.rb
@@ -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
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/dc825ac2e3440e55b35ce985a378c626988ac2f2...0726343b81fc2f8c914333f548564ba83f61a941
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151228/9d131683/attachment.html>
More information about the Noosfero-dev
mailing list