From 3731d14fe303892ba4909ca050a07e941c3f4f94 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 1 Dec 2015 09:47:05 -0300 Subject: [PATCH] software-communities: extract category hardcoded extensions (checkpoint) --- src/noosfero-spb/software_communities/lib/ext/category.rb | 26 -------------------------- src/noosfero-spb/software_communities/lib/ext/search_controller.rb | 4 ++-- src/noosfero-spb/software_communities/lib/software_communities_plugin.rb | 26 ++++++++++++++++++++++++++ src/noosfero-spb/software_communities/lib/tasks/create_categories.rake | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/noosfero-spb/software_communities/lib/ext/category.rb b/src/noosfero-spb/software_communities/lib/ext/category.rb index 0c3008c..2ea0118 100644 --- a/src/noosfero-spb/software_communities/lib/ext/category.rb +++ b/src/noosfero-spb/software_communities/lib/ext/category.rb @@ -1,32 +1,6 @@ require_dependency 'category' class Category - SOFTWARE_CATEGORIES = [ - _('Agriculture, Fisheries and Extraction'), - _('Science, Information and Communication'), - _('Economy and Finances'), - _('Public Administration'), - _('Habitation, Sanitation and Urbanism'), - _('Individual, Family and Society'), - _('Health'), - _('Social Welfare and Development'), - _('Defense and Security'), - _('Education'), - _('Government and Politics'), - _('Justice and Legislation'), - _('International Relationships'), - _('Transportation and Transit') - ] - - scope :software_categories, lambda { - software_category = Category.find_by_name("Software") - if software_category.nil? - [] - else - software_category.children - end - } - def software_infos software_list = self.communities software_list.collect { |x| software_list.delete(x) unless x.software? } diff --git a/src/noosfero-spb/software_communities/lib/ext/search_controller.rb b/src/noosfero-spb/software_communities/lib/ext/search_controller.rb index cdc2116..e008f4c 100644 --- a/src/noosfero-spb/software_communities/lib/ext/search_controller.rb +++ b/src/noosfero-spb/software_communities/lib/ext/search_controller.rb @@ -151,12 +151,12 @@ class SearchController end def prepare_software_infos_category_groups - @categories = Category.software_categories.sort{|a, b| a.name <=> b.name} + @categories = SoftwareCommunitiesPlugin.software_categories.sort{|a, b| a.name <=> b.name} end def prepare_software_infos_category_enable @enabled_check_box = Hash.new - categories = Category.software_categories + categories = SoftwareCommunitiesPlugin.software_categories categories.each do |category| if category.software_infos.count > 0 diff --git a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb index e2d2c2d..939d20c 100644 --- a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb +++ b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb @@ -17,6 +17,23 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin _('Add Public Software and MPOG features.') end + SOFTWARE_CATEGORIES = [ + _('Agriculture, Fisheries and Extraction'), + _('Science, Information and Communication'), + _('Economy and Finances'), + _('Public Administration'), + _('Habitation, Sanitation and Urbanism'), + _('Individual, Family and Society'), + _('Health'), + _('Social Welfare and Development'), + _('Defense and Security'), + _('Education'), + _('Government and Politics'), + _('Justice and Legislation'), + _('International Relationships'), + _('Transportation and Transit') + ] + def profile_tabs if context.profile.community? && context.profile.software? return profile_tabs_software @@ -47,6 +64,15 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin } end + def self.software_categories + software_category = Category.find_by_name("Software") + if software_category.nil? + [] + else + software_category.children + end + end + def stylesheet? true end diff --git a/src/noosfero-spb/software_communities/lib/tasks/create_categories.rake b/src/noosfero-spb/software_communities/lib/tasks/create_categories.rake index 29a1cf9..f1b9ab8 100644 --- a/src/noosfero-spb/software_communities/lib/tasks/create_categories.rake +++ b/src/noosfero-spb/software_communities/lib/tasks/create_categories.rake @@ -5,7 +5,7 @@ namespace :software do if env.plugin_enabled?("SoftwareCommunitiesPlugin") or env.plugin_enabled?("SoftwareCommunities") print 'Creating categories: ' software = Category.create(:name => _("Software"), :environment => env) - Category::SOFTWARE_CATEGORIES.each do |category_name| + SoftwareCommunitiesPlugin::SOFTWARE_CATEGORIES.each do |category_name| unless Category.find_by_name(category_name) print '.' Category.create(:name => category_name, :environment => env, :parent => software) -- libgit2 0.21.2