Commit 55dbc94439956b0a52f82e4c2eebb55398dc7002

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 69a6bc08

Renamed ControlledVocabulary to SoftwareCategories in all plugin

(correcoes_aderencia)

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
... ... @@ -17,7 +17,7 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
17 17 @list_libraries = LibraryHelper.list_libraries(params[:library])
18 18 @list_languages = SoftwareLanguageHelper.list_language(params[:language])
19 19 @list_databases = DatabaseHelper.list_database(params[:database])
20   - @controlled_vocabulary = ControlledVocabulary::new params[:controlled_vocabulary]
  20 + @software_categories = SoftwareCategories::new params[:software_categories]
21 21 @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system])
22 22 @license_info = if params[:license_info].nil?
23 23 LicenseInfo::new
... ... @@ -58,7 +58,8 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
58 58 valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems)
59 59  
60 60 if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system
61   - @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary)
  61 +
  62 + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @software_categories)
62 63  
63 64 unless params[:q].nil?
64 65 admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i}
... ...
db/migrate/20140909185547_rename_controlled_vocabulary_to_software_categories.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class RenameControlledVocabularyToSoftwareCategories < ActiveRecord::Migration
  2 + def up
  3 + rename_table :controlled_vocabulary, :software_categories
  4 + end
  5 +
  6 + def down
  7 + rename_table :software_categories, :controlled_vocabulary
  8 + end
  9 +end
... ...
lib/controlled_vocabulary_helper.rb
... ... @@ -1,15 +0,0 @@
1   -module ControlledVocabularyHelper
2   -
3   - def self.get_categories_as_options
4   - categories = ["<option value = #{""} >Any</option>".html_safe]
5   - value = 1
6   -
7   - ControlledVocabulary.attribute_names.each do |attribute|
8   - if attribute.to_s != "id" && attribute.to_s != "software_info_id" then
9   - categories << "<option value = #{attribute} >#{attribute.titleize}</option>".html_safe
10   - value+=1
11   - end
12   - end
13   - categories
14   - end
15   -end
lib/ext/community.rb
... ... @@ -7,17 +7,17 @@ class Community
7 7 has_one :software_info, :dependent=>:delete
8 8 has_one :institution, :dependent=>:delete
9 9  
10   - def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil)
  10 + def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, software_categories = nil)
11 11 community = Community.new(attributes)
12 12  
13 13 if not software_info.nil?
14   - if not license_info.nil?
15   - software_info.license_info = license_info
16   - end
  14 + if not license_info.nil?
  15 + software_info.license_info = license_info
  16 + end
17 17  
18   - if not controlled_vocabulary.nil?
19   - software_info.controlled_vocabulary = controlled_vocabulary
20   - end
  18 + if not software_categories.nil?
  19 + software_info.software_categories = software_categories
  20 + end
21 21 software_info.save
22 22 end
23 23  
... ...
lib/ext/controlled_vocabulary.rb
... ... @@ -1,12 +0,0 @@
1   -class ControlledVocabulary < ActiveRecord::Base
2   - self.table_name = "controlled_vocabulary"
3   -
4   - attr_accessible :administration , :agriculture , :business_and_services , :communication ,
5   - :culture , :national_defense , :economy_and_finances , :education ,
6   - :energy , :sports , :habitation , :industry , :environment ,
7   - :research_and_development , :social_security , :social_protection ,
8   - :international_relations , :sanitation , :health ,
9   - :security_public_order , :work , :transportation , :urbanism
10   -
11   - belongs_to :software_info
12   -end
13 0 \ No newline at end of file
lib/mpog_software_plugin.rb
... ... @@ -100,8 +100,8 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
100 100 institution_transaction
101 101 end
102 102  
103   - if context.params.has_key?(:controlled_vocabulary)
104   - controlled_vocabulary_transaction
  103 + if context.params.has_key?(:software_categories)
  104 + software_categories_transaction
105 105 end
106 106 elsif context.profile.respond_to?(:user)
107 107 if context.params.has_key?(:user)
... ... @@ -137,7 +137,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
137 137 softwares = SoftwareInfo.search(params[:name], params[:database_description][:id],
138 138 params[:programming_language][:id], params[:operating_system][:id],
139 139 params[:license_info][:id], params[:e_ping], params[:e_mag], params[:internacionalizable],
140   - params[:icp_brasil], params[:e_arq], params[:controlled_vocabulary])
  140 + params[:icp_brasil], params[:e_arq], params[:software_categories])
141 141 communities = []
142 142  
143 143 softwares.each do |s|
... ... @@ -416,9 +416,9 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
416 416 end
417 417 end
418 418  
419   - def controlled_vocabulary_transaction
  419 + def software_categories_transaction
420 420 ControlledVocabulary.transaction do
421   - context.profile.software_info.controlled_vocabulary.update_attributes!(context.params[:controlled_vocabulary])
  421 + context.profile.software_info.software_categories.update_attributes!(context.params[:software_categories])
422 422 end
423 423 end
424 424  
... ...
lib/software_categories.rb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +class SoftwareCategories < ActiveRecord::Base
  2 + attr_accessible :administration , :agriculture , :business_and_services , :communication ,
  3 + :culture , :national_defense , :economy_and_finances , :education ,
  4 + :energy , :sports , :habitation , :industry , :environment ,
  5 + :research_and_development , :social_security , :social_protection ,
  6 + :international_relations , :sanitation , :health ,
  7 + :security_public_order , :work , :transportation , :urbanism
  8 +
  9 + belongs_to :software_info
  10 +end
0 11 \ No newline at end of file
... ...
lib/software_categories_helper.rb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +module SoftwareCategoriesHelper
  2 +
  3 + def self.get_categories_as_options
  4 + categories = ["<option value = #{""} >Any</option>".html_safe]
  5 + value = 1
  6 +
  7 + SoftwareCategories.attribute_names.each do |attribute|
  8 + if attribute.to_s != "id" && attribute.to_s != "software_info_id" then
  9 + categories << "<option value = #{attribute} >#{attribute.titleize}</option>".html_safe
  10 + value+=1
  11 + end
  12 + end
  13 + categories
  14 + end
  15 +end
... ...
lib/software_info.rb
... ... @@ -12,7 +12,9 @@ class SoftwareInfo &lt; ActiveRecord::Base
12 12 belongs_to :community
13 13 belongs_to :license_info
14 14  
15   - has_one :controlled_vocabulary
  15 + has_one :software_categories
  16 +
  17 + validates :software_categories, :presence=>true
16 18  
17 19 validates :features, :objectives,
18 20 :presence=>true,
... ... @@ -31,7 +33,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
31 33 scope :search, lambda { |name="", database_description_id = "",
32 34 programming_language_id = "", operating_system_name_id = "",
33 35 license_info_id = "", e_ping = "", e_mag = "", internacionalizable = "",
34   - icp_brasil = "", e_arq = "", controlled_vocabulary = "" |
  36 + icp_brasil = "", e_arq = "", software_categories = "" |
35 37  
36 38 like_sql = ""
37 39 values = []
... ... @@ -86,9 +88,9 @@ class SoftwareInfo &lt; ActiveRecord::Base
86 88 values << "#{e_arq}"
87 89 end
88 90  
89   - unless controlled_vocabulary.blank?
90   - controlled_vocabulary = controlled_vocabulary.gsub(' ', '').underscore
91   - like_sql << "controlled_vocabulary.#{controlled_vocabulary} = ? AND "
  91 + unless software_categories.blank?
  92 + software_categories = software_categories.gsub(' ', '').underscore
  93 + like_sql << "software_categories.#{software_categories} = ? AND "
92 94 values << "true"
93 95 end
94 96  
... ... @@ -96,7 +98,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
96 98  
97 99 {
98 100 :joins => [:community, :software_databases, :software_languages,
99   - :operating_systems, :controlled_vocabulary],
  101 + :operating_systems, :software_categories],
100 102 :conditions=>[like_sql, *values]
101 103 }
102 104 }
... ...
test/unit/controlled_vocabulary_test.rb
... ... @@ -1,59 +0,0 @@
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
2   -
3   -class ControlledVocabularyTest < ActiveSupport::TestCase
4   -
5   - def setup
6   - @community = fast_create(Community, :identifier => 'new-software', :name => 'New Software')
7   -
8   - @language = ProgrammingLanguage.new(:name => 'C++')
9   - @language.save
10   - @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os')
11   - @software_language.programming_language = @language
12   - @software_language.save
13   -
14   - @database = DatabaseDescription.new(:name => 'Oracle')
15   - @database.save
16   - @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2')
17   - @software_database.database_description = @database
18   - @software_database.save
19   -
20   - @operating_system_name = OperatingSystemName.new(:name => 'Debian')
21   - @operating_system_name.save
22   - @operating_system = OperatingSystem.new(:version => '1.0')
23   - @operating_system.operating_system_name = @operating_system_name
24   - @operating_system.save
25   -
26   - @software_info = SoftwareInfo.new(:acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true,
27   - :e_arq => true, :operating_platform => true, :objectives => "", :features => "")
28   - @software_info.software_languages << @software_language
29   - @software_info.software_databases << @software_database
30   - @software_info.operating_systems << @operating_system
31   -
32   - @controlled_language = ControlledVocabulary.new()
33   - @controlled_vocabulary = ControlledVocabulary.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true,
34   - :culture => true, :national_defense => true, :economy_and_finances => true, :education => true,
35   - :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true,
36   - :research_and_development => true, :social_security => false , :social_protection => true,
37   - :international_relations => true, :sanitation => true, :health => false,
38   - :security_public_order => true, :work => true, :transportation => true, :urbanism => true)
39   - @software_info.controlled_vocabulary = @controlled_vocabulary
40   - end
41   -
42   - should "save software correctly with ControlledVocabulary filds" do
43   - assert @software_info.save
44   - end
45   -
46   - should "set in software_info a reference to controlled_vocabulary" do
47   - @software_info.save
48   - @controlled_vocabulary.save
49   - assert_equal SoftwareInfo.last.controlled_vocabulary, ControlledVocabulary.last
50   - end
51   -
52   - should "return a valid value from database" do
53   - @software_info.save
54   - @controlled_vocabulary.save
55   - software_info = SoftwareInfo.find(@software_info.id)
56   - controlled_vocabulary = ControlledVocabulary.find(software_info.controlled_vocabulary)
57   - assert_equal true, controlled_vocabulary.education
58   - end
59   -end
test/unit/software_categories_test.rb 0 → 100644
... ... @@ -0,0 +1,61 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +
  3 +class SoftwareCategoriesTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @community = fast_create(Community, :identifier => 'new-software', :name => 'New Software')
  7 +
  8 + @language = ProgrammingLanguage.new(:name => 'C++')
  9 + @language.save
  10 + @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os')
  11 + @software_language.programming_language = @language
  12 + @software_language.save
  13 +
  14 + @database = DatabaseDescription.new(:name => 'Oracle')
  15 + @database.save
  16 + @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2')
  17 + @software_database.database_description = @database
  18 + @software_database.save
  19 +
  20 + @operating_system_name = OperatingSystemName.new(:name => 'Debian')
  21 + @operating_system_name.save
  22 + @operating_system = OperatingSystem.new(:version => '1.0')
  23 + @operating_system.operating_system_name = @operating_system_name
  24 + @operating_system.save
  25 +
  26 + @software_info = SoftwareInfo.new(:acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true,
  27 + :e_arq => true, :operating_platform => true, :objectives => "", :features => "")
  28 + @software_info.software_languages << @software_language
  29 + @software_info.software_databases << @software_database
  30 + @software_info.operating_systems << @operating_system
  31 +
  32 + @software_info.features = "Do a lot of things"
  33 + @software_info.objectives = "All tests should pass !"
  34 +
  35 + @software_categories = SoftwareCategories.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true,
  36 + :culture => true, :national_defense => true, :economy_and_finances => true, :education => true,
  37 + :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true,
  38 + :research_and_development => true, :social_security => false , :social_protection => true,
  39 + :international_relations => true, :sanitation => true, :health => false,
  40 + :security_public_order => true, :work => true, :transportation => true, :urbanism => true)
  41 + @software_info.software_categories = @software_categories
  42 + end
  43 +
  44 + should "save software correctly with SoftwareCategories filds" do
  45 + assert @software_info.save
  46 + end
  47 +
  48 + should "set in software_info a reference to software_categories" do
  49 + @software_info.save
  50 + @software_categories.save
  51 + assert_equal SoftwareInfo.last.software_categories, SoftwareCategories.last
  52 + end
  53 +
  54 + should "return a valid value from database" do
  55 + @software_info.save
  56 + @software_categories.save
  57 + software_info = SoftwareInfo.find(@software_info.id)
  58 + software_categories = SoftwareCategories.find(software_info.software_categories)
  59 + assert_equal true, software_categories.education
  60 + end
  61 +end
... ...
views/mpog_software_plugin_myprofile/new_software.html.erb
... ... @@ -151,9 +151,9 @@ offerers&#39;), :pre_populate =&gt; @tokenized_children}) %&gt;
151 151 <%= render :partial => 'database_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :database => @list_databases } %>
152 152 </div>
153 153  
154   - <%= fields_for @controlled_vocabulary do |cv| %>
155   - <div id="controlled_vocabulary_fields">
156   - <h4> <%= _("Controlled Vocabulary of E-government") %> </h4>
  154 + <%= fields_for @software_categories do |cv| %>
  155 + <div id="software_categories_fields">
  156 + <h4> <%= _("Software Categories:") %> </h4>
157 157  
158 158 <%= cv.check_box :administration %>
159 159 <%= cv.label :administration, _("Administration") %><br />
... ...
views/search/search_forms/_software_fields.html.erb
... ... @@ -26,9 +26,9 @@
26 26 </tr>
27 27  
28 28 <tr>
29   - <td> <%= _("Controlled Vocabulary") %> </td>
  29 + <td> <%= _("Software Categories") %> </td>
30 30 <td>
31   - <%= select_tag("controlled_vocabulary", (ControlledVocabularyHelper.get_categories_as_options)) %>
  31 + <%= select_tag("software_categories", (SoftwareCategoriesHelper.get_categories_as_options)) %>
32 32 </td>
33 33 </tr>
34 34  
... ...
views/software_editor_extras.html.erb
... ... @@ -95,52 +95,52 @@
95 95 <div id='table_structure_databases' style="display:none"><%= DatabaseHelper.add_dynamic_table %></div>
96 96 <%= link_to _('New Database'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-databases"%>
97 97  
98   -<div id="controlled_vocabulary_fields">
99   -<h4> <%= _("Controlled Vocabulary of E-government") %> </h4>
  98 +<div id="software_categories_fields">
  99 +<h4> <%= _("Software Categories") %> </h4>
100 100  
101   - <%= labelled_check_box _("Administration"), "controlled_vocabulary[administration]", "1", context.profile.software_info.controlled_vocabulary.administration %> <br />
  101 + <%= labelled_check_box _("Administration"), "software_categories[administration]", "1", context.profile.software_info.software_categories.administration %> <br />
102 102  
103   - <%= labelled_check_box _("Agriculture"), "controlled_vocabulary[agriculture]", "1", context.profile.software_info.controlled_vocabulary.agriculture %> <br />
  103 + <%= labelled_check_box _("Agriculture"), "software_categories[agriculture]", "1", context.profile.software_info.software_categories.agriculture %> <br />
104 104  
105   - <%= labelled_check_box _("Business_and Services"), "controlled_vocabulary[business_and_services]", "1", context.profile.software_info.controlled_vocabulary.business_and_services %> <br />
  105 + <%= labelled_check_box _("Business_and Services"), "software_categories[business_and_services]", "1", context.profile.software_info.software_categories.business_and_services %> <br />
106 106  
107   - <%= labelled_check_box _("Communication"), "controlled_vocabulary[communication]", "1", context.profile.software_info.controlled_vocabulary.communication %> <br />
  107 + <%= labelled_check_box _("Communication"), "software_categories[communication]", "1", context.profile.software_info.software_categories.communication %> <br />
108 108  
109   - <%= labelled_check_box _("Culture"), "controlled_vocabulary[culture]", "1", context.profile.software_info.controlled_vocabulary.culture %> <br />
  109 + <%= labelled_check_box _("Culture"), "software_categories[culture]", "1", context.profile.software_info.software_categories.culture %> <br />
110 110  
111   - <%= labelled_check_box _("National Defense"), "controlled_vocabulary[national_defense]", "1", context.profile.software_info.controlled_vocabulary.national_defense %> <br />
  111 + <%= labelled_check_box _("National Defense"), "software_categories[national_defense]", "1", context.profile.software_info.software_categories.national_defense %> <br />
112 112  
113   - <%= labelled_check_box _("Economy and Finances"), "controlled_vocabulary[economy_and_finances]", "1", context.profile.software_info.controlled_vocabulary.economy_and_finances %> <br />
  113 + <%= labelled_check_box _("Economy and Finances"), "software_categories[economy_and_finances]", "1", context.profile.software_info.software_categories.economy_and_finances %> <br />
114 114  
115   - <%= labelled_check_box _("Education"), "controlled_vocabulary[education]", "1", context.profile.software_info.controlled_vocabulary.education %> <br />
  115 + <%= labelled_check_box _("Education"), "software_categories[education]", "1", context.profile.software_info.software_categories.education %> <br />
116 116  
117   - <%= labelled_check_box _("Energy"), "controlled_vocabulary[energy]", "1", context.profile.software_info.controlled_vocabulary.energy %> <br />
  117 + <%= labelled_check_box _("Energy"), "software_categories[energy]", "1", context.profile.software_info.software_categories.energy %> <br />
118 118  
119   - <%= labelled_check_box _("Sports"), "controlled_vocabulary[sports]", "1", context.profile.software_info.controlled_vocabulary.sports %> <br />
  119 + <%= labelled_check_box _("Sports"), "software_categories[sports]", "1", context.profile.software_info.software_categories.sports %> <br />
120 120  
121   - <%= labelled_check_box _("Habitation"), "controlled_vocabulary[habitation]", "1", context.profile.software_info.controlled_vocabulary.habitation %> <br />
  121 + <%= labelled_check_box _("Habitation"), "software_categories[habitation]", "1", context.profile.software_info.software_categories.habitation %> <br />
122 122  
123   - <%= labelled_check_box _("Industry"), "controlled_vocabulary[industry]", "1", context.profile.software_info.controlled_vocabulary.industry %> <br />
  123 + <%= labelled_check_box _("Industry"), "software_categories[industry]", "1", context.profile.software_info.software_categories.industry %> <br />
124 124  
125   - <%= labelled_check_box _("Environment"), "controlled_vocabulary[environment]", "1", context.profile.software_info.controlled_vocabulary.environment %> <br />
  125 + <%= labelled_check_box _("Environment"), "software_categories[environment]", "1", context.profile.software_info.software_categories.environment %> <br />
126 126  
127   - <%= labelled_check_box _("Research and Development"), "controlled_vocabulary[research_and_development]", "1", context.profile.software_info.controlled_vocabulary.research_and_development %> <br />
  127 + <%= labelled_check_box _("Research and Development"), "software_categories[research_and_development]", "1", context.profile.software_info.software_categories.research_and_development %> <br />
128 128  
129   - <%= labelled_check_box _("Social Security"), "controlled_vocabulary[social_security]", "1", context.profile.software_info.controlled_vocabulary.social_security %> <br />
  129 + <%= labelled_check_box _("Social Security"), "software_categories[social_security]", "1", context.profile.software_info.software_categories.social_security %> <br />
130 130  
131   - <%= labelled_check_box _("Social Protection"), "controlled_vocabulary[social_protection]", "1", context.profile.software_info.controlled_vocabulary.social_protection %> <br />
  131 + <%= labelled_check_box _("Social Protection"), "software_categories[social_protection]", "1", context.profile.software_info.software_categories.social_protection %> <br />
132 132  
133   - <%= labelled_check_box _("Sanitation"), "controlled_vocabulary[sanitation]", "1", context.profile.software_info.controlled_vocabulary.sanitation %> <br />
  133 + <%= labelled_check_box _("Sanitation"), "software_categories[sanitation]", "1", context.profile.software_info.software_categories.sanitation %> <br />
134 134  
135   - <%= labelled_check_box _("Health"), "controlled_vocabulary[health]", "1", context.profile.software_info.controlled_vocabulary.health %> <br />
  135 + <%= labelled_check_box _("Health"), "software_categories[health]", "1", context.profile.software_info.software_categories.health %> <br />
136 136  
137   - <%= labelled_check_box _("Security and Public Order"), "controlled_vocabulary[security_public_order]", "1", context.profile.software_info.controlled_vocabulary.security_public_order %> <br />
  137 + <%= labelled_check_box _("Security and Public Order"), "software_categories[security_public_order]", "1", context.profile.software_info.software_categories.security_public_order %> <br />
138 138  
139   - <%= labelled_check_box _("Work"), "controlled_vocabulary[work]", "1", context.profile.software_info.controlled_vocabulary.work %> <br />
  139 + <%= labelled_check_box _("Work"), "software_categories[work]", "1", context.profile.software_info.software_categories.work %> <br />
140 140  
141   - <%= labelled_check_box _("Transportation"), "controlled_vocabulary[transportation]", "1", context.profile.software_info.controlled_vocabulary.transportation %> <br />
  141 + <%= labelled_check_box _("Transportation"), "software_categories[transportation]", "1", context.profile.software_info.software_categories.transportation %> <br />
142 142  
143   - <%= labelled_check_box _("Urbanism"), "controlled_vocabulary[urbanism]", "1", context.profile.software_info.controlled_vocabulary.urbanism %> <br />
  143 + <%= labelled_check_box _("Urbanism"), "software_categories[urbanism]", "1", context.profile.software_info.software_categories.urbanism %> <br />
144 144 </div>
145 145  
146 146 <h3> <%= _("Operating System") %> </h3>
... ...