Commit d5c76ada8c88e6d0a8f99d432e907f2b7cd34e2a

Authored by Tallys Martins
1 parent 1c8c8adb
Exists in sisp_dev

Fix categories search for multi environments

Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
src/noosfero-spb/gov_user/lib/public_institution.rb
... ... @@ -2,8 +2,6 @@ class PublicInstitution &lt; Institution
2 2 validates :governmental_power, :governmental_sphere, :juridical_nature,
3 3 :presence=>true
4 4  
5   - validates :acronym, :allow_blank => true, :allow_nil => true
6   -
7 5 validates :cnpj,
8 6 :format => {with: CNPJ_FORMAT},
9 7 :unless => 'cnpj.blank?'
... ...
src/noosfero-spb/noosfero-spb-theme/css/software-catalog-page.css
... ... @@ -628,9 +628,9 @@
628 628 .action-search-sisp #filter-catalog-software #filter-categories-option {
629 629 border: none;
630 630 height: 0;
631   - max-height: 620px;
  631 + max-height: auto;
632 632 position: relative;
633   - overflow: hidden;
  633 + overflow: auto;
634 634 padding: 0 15px;
635 635 }
636 636  
... ...
src/noosfero-spb/software_communities/lib/categories_software_block.rb
... ... @@ -19,7 +19,7 @@ class CategoriesSoftwareBlock &lt; Block
19 19 block = self
20 20 s = show_name
21 21  
22   - software_category = Category.find_by_name("Software")
  22 + software_category = environment.categories.find_by_name("Software")
23 23 categories = []
24 24 categories = software_category.children.sort if software_category
25 25  
... ...
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
... ... @@ -177,7 +177,9 @@ class SearchController
177 177 end
178 178  
179 179 def prepare_software_infos_category_groups &software_condition_block
180   - @categories = Category.software_categories
  180 + @categories = []
  181 + software_category = environment.categories.find_by_name("Software")
  182 + @categories = software_category.children.sort if software_category
181 183 @categories = @categories.select{|category| category.software_infos.any?{|software| software_condition_block.call(software)}}
182 184 @categories.sort!{|a, b| a.name <=> b.name}
183 185 end
... ...
src/noosfero-spb/software_communities/lib/tasks/create_categories.rake
... ... @@ -4,9 +4,9 @@ namespace :software do
4 4 Environment.all.each do |env|
5 5 if env.plugin_enabled?("SoftwareCommunitiesPlugin") or env.plugin_enabled?("SoftwareCommunities")
6 6 print 'Creating categories: '
7   - software = Category.create(:name => _("Software"), :environment => env)
  7 + software = env.categories.find_or_create_by_name(_("Software"))
8 8 Category::SOFTWARE_CATEGORIES.each do |category_name|
9   - unless Category.find_by_name(category_name)
  9 + unless env.categories.find_by_name(category_name)
10 10 print '.'
11 11 Category.create(:name => category_name, :environment => env, :parent => software)
12 12 else
... ...
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
... ... @@ -86,7 +86,7 @@ namespace :sisp do
86 86 $imported_data = YAML.load_file('plugins/software_communities/public/static/sisp-catalog.yml')
87 87 $env = Environment.find_by_name("SISP")
88 88  
89   - $software_category = Category.find_or_create_by_name("Software")
  89 + $software_category = $env.categories.find_or_create_by_name("Software")
90 90 $software_category.environment = $env
91 91 $software_category.save!
92 92  
... ...