diff --git a/controllers/software_communities_plugin_controller.rb b/controllers/software_communities_plugin_controller.rb index 16ff893..0d59ad8 100644 --- a/controllers/software_communities_plugin_controller.rb +++ b/controllers/software_communities_plugin_controller.rb @@ -42,11 +42,7 @@ class SoftwareCommunitiesPluginController < ApplicationController protected def get_model_by_params_field - case params[:field] - when "software_language" - return ProgrammingLanguage - else - return DatabaseDescription - end + return DatabaseDescription unless params[:field] == "software_language" + return ProgrammingLanguage end end diff --git a/controllers/software_communities_plugin_myprofile_controller.rb b/controllers/software_communities_plugin_myprofile_controller.rb index eda06e2..f6cfe4f 100644 --- a/controllers/software_communities_plugin_myprofile_controller.rb +++ b/controllers/software_communities_plugin_myprofile_controller.rb @@ -26,7 +26,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController return unless request.post? - @software_info = constroy_software + @software_info = create_software software_info_insert_models.call(@list_libraries, 'libraries') software_info_insert_models.call(@list_languages, 'software_languages') software_info_insert_models.call(@list_databases, 'software_databases') @@ -87,7 +87,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController } end - def constroy_software + def create_software @software_info = @profile.software_info params[:software][:public_software] ||= false unless @software_info.public_software? @license = LicenseInfo.find(params[:license][:license_infos_id]) diff --git a/lib/database_helper.rb b/lib/database_helper.rb index af7f5e2..94bf652 100644 --- a/lib/database_helper.rb +++ b/lib/database_helper.rb @@ -34,12 +34,7 @@ class DatabaseHelper < DynamicTableHelper def self.valid_list_database? list_databases return false if list_databases.nil? or list_databases.length == 0 - - list_databases.each do |database| - return false unless database.valid? - end - - true + return !list_databases.any?{|database| !database.valid?} end def self.database_as_tables(list_databases, disabled=false) @@ -51,14 +46,10 @@ class DatabaseHelper < DynamicTableHelper def self.database_html_structure(database_data, disabled) database_id = database_data[:database_description_id] - database_name = if database_data[:database_description_id].blank? - "" - else - DatabaseDescription.find( + database_name = database_id.blank? ? "" : DatabaseDescription.find( database_data[:database_description_id], :select=>"name" ).name - end data = { model_name: MODEL_NAME, @@ -83,4 +74,4 @@ class DatabaseHelper < DynamicTableHelper def self.add_dynamic_table database_as_tables(nil).first.call end -end \ No newline at end of file +end diff --git a/lib/library_helper.rb b/lib/library_helper.rb index dfb0953..579ebb7 100644 --- a/lib/library_helper.rb +++ b/lib/library_helper.rb @@ -20,12 +20,7 @@ class LibraryHelper < DynamicTableHelper def self.valid_list_library? list_libraries return true if list_libraries.nil? or list_libraries.length == 0 - - list_libraries.each do |library| - return false unless library.valid? - end - - true + return !list_libraries.any?{|library| !library.valid?} end def self.libraries_as_tables list_libraries, disabled=false @@ -59,4 +54,4 @@ class LibraryHelper < DynamicTableHelper def self.add_dynamic_table libraries_as_tables(nil).first.call end -end \ No newline at end of file +end diff --git a/lib/operating_system_helper.rb b/lib/operating_system_helper.rb index d5bd9a9..201ac05 100644 --- a/lib/operating_system_helper.rb +++ b/lib/operating_system_helper.rb @@ -25,12 +25,8 @@ class OperatingSystemHelper < DynamicTableHelper end def self.valid_list_operating_system? list_operating_system - return !(list_operating_system.nil? || list_operating_system.length == 0) - - list_operating_system.each do |operating_system| - return false unless operating_system.valid? - end - true + return false if (list_operating_system.nil? || list_operating_system.length == 0) + return !list_operating_system.any?{|os| !os.valid?} end def self.operating_system_as_tables(list_operating_system, disabled=false) diff --git a/lib/software_communities_plugin.rb b/lib/software_communities_plugin.rb index ac1e481..b78d762 100644 --- a/lib/software_communities_plugin.rb +++ b/lib/software_communities_plugin.rb @@ -18,8 +18,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin end def profile_tabs - if context.profile.community? - return profile_tabs_software if context.profile.software? + if context.profile.community? && context.profile.software? + return profile_tabs_software end end diff --git a/lib/software_helper.rb b/lib/software_helper.rb index c5159d2..47ce223 100644 --- a/lib/software_helper.rb +++ b/lib/software_helper.rb @@ -23,14 +23,6 @@ module SoftwareHelper end def self.all_table_is_empty? table, ignored_fields=[] - filled_fields = [] - - table.each do |key, value| - unless ignored_fields.include? key - filled_fields << !value.empty? - end - end - - return !filled_fields.include?(true) + return !table.keys.any?{|key| ignored_fields.include?(key) ? false : !table[key].empty?} end end -- libgit2 0.21.2