Commit 228e43c28a958a90b9944311e45ff1ad5286f354
Committed by
Luciano Prestes
1 parent
353a9563
Exists in
software_as_organization
begin refactoring
Showing
4 changed files
with
66 additions
and
21 deletions
Show diff stats
src/noosfero-spb/software_communities/db/migrate/20151125175514_change_software_info_structure.rb
0 → 100644
| @@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
| 1 | +class CreateSispInfo < ActiveRecord::Migration | ||
| 2 | + def up | ||
| 3 | + create_table :sosftware_infos do |t| | ||
| 4 | + t.integer :software_id | ||
| 5 | + t.text :agency_identification | ||
| 6 | + t.text :softawre_requirements | ||
| 7 | + t.text :hardware_requirements | ||
| 8 | + t.text :documentation | ||
| 9 | + t.text :system_applications | ||
| 10 | + t.text :active_versions | ||
| 11 | + t.text :estimated_cost | ||
| 12 | + t.text :responsible | ||
| 13 | + t.text :responsible_for_acquirement | ||
| 14 | + t.text :system_info | ||
| 15 | + t.text :development_info | ||
| 16 | + t.text :maintenance | ||
| 17 | + t.text :standards_adherence | ||
| 18 | + t.text :plataform | ||
| 19 | + t.text :sisp_type | ||
| 20 | + end | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | + def down | ||
| 24 | + drop_table :software_infos | ||
| 25 | + end | ||
| 26 | +end |
src/noosfero-spb/software_communities/lib/software_info.rb
| @@ -8,7 +8,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -8,7 +8,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 8 | 8 | ||
| 9 | SEARCHABLE_SOFTWARE_CLASSES = [ | 9 | SEARCHABLE_SOFTWARE_CLASSES = [ |
| 10 | SoftwareInfo, | 10 | SoftwareInfo, |
| 11 | - Community, | 11 | + Software, |
| 12 | ProgrammingLanguage, | 12 | ProgrammingLanguage, |
| 13 | DatabaseDescription | 13 | DatabaseDescription |
| 14 | ] | 14 | ] |
| @@ -18,7 +18,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -18,7 +18,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 18 | search_fields = SoftwareInfo.pg_search_plugin_fields | 18 | search_fields = SoftwareInfo.pg_search_plugin_fields |
| 19 | 19 | ||
| 20 | if query.empty? | 20 | if query.empty? |
| 21 | - SoftwareInfo.joins(:community).where("profiles.visible = ?", true) | 21 | + SoftwareInfo.joins(:software).where("profiles.visible = ?", true) |
| 22 | else | 22 | else |
| 23 | searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES) | 23 | searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES) |
| 24 | includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ?", true) | 24 | includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ?", true) |
| @@ -65,7 +65,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -65,7 +65,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 65 | attr_accessible :demonstration_url, :acronym, :objectives, :features, | 65 | attr_accessible :demonstration_url, :acronym, :objectives, :features, |
| 66 | :license_info | 66 | :license_info |
| 67 | 67 | ||
| 68 | - attr_accessible :community_id, :finality, :repository_link, :public_software, | 68 | + attr_accessible :software_id, :finality, :repository_link, :public_software, |
| 69 | :first_edit | 69 | :first_edit |
| 70 | 70 | ||
| 71 | has_many :libraries, :dependent => :destroy | 71 | has_many :libraries, :dependent => :destroy |
| @@ -76,7 +76,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -76,7 +76,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 76 | has_many :programming_languages, :through => :software_languages | 76 | has_many :programming_languages, :through => :software_languages |
| 77 | has_many :operating_system_names, :through => :operating_systems | 77 | has_many :operating_system_names, :through => :operating_systems |
| 78 | 78 | ||
| 79 | - belongs_to :community, :dependent => :destroy | 79 | + belongs_to :software, :dependent => :destroy |
| 80 | belongs_to :license_info | 80 | belongs_to :license_info |
| 81 | 81 | ||
| 82 | has_one :software_categories | 82 | has_one :software_categories |
| @@ -84,7 +84,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -84,7 +84,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 84 | validates_length_of :finality, :maximum => 120 | 84 | validates_length_of :finality, :maximum => 120 |
| 85 | validates_length_of :objectives, :maximum => 4000 | 85 | validates_length_of :objectives, :maximum => 4000 |
| 86 | validates_length_of :features, :maximum => 4000 | 86 | validates_length_of :features, :maximum => 4000 |
| 87 | - validates_presence_of :finality, :community | 87 | + validates_presence_of :finality, :software |
| 88 | 88 | ||
| 89 | validate :validate_acronym | 89 | validate :validate_acronym |
| 90 | 90 | ||
| @@ -92,7 +92,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -92,7 +92,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 92 | 92 | ||
| 93 | # used on find_by_contents | 93 | # used on find_by_contents |
| 94 | scope :like_search, lambda{ |name| | 94 | scope :like_search, lambda{ |name| |
| 95 | - joins(:community).where( | 95 | + joins(:software).where( |
| 96 | "name ILIKE ? OR acronym ILIKE ? OR finality ILIKE ?", | 96 | "name ILIKE ? OR acronym ILIKE ? OR finality ILIKE ?", |
| 97 | "%#{name}%", "%#{name}%", "%#{name}%" | 97 | "%#{name}%", "%#{name}%", "%#{name}%" |
| 98 | ) | 98 | ) |
| @@ -114,11 +114,15 @@ class SoftwareInfo < ActiveRecord::Base | @@ -114,11 +114,15 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 114 | like_sql = like_sql[0..like_sql.length-5] | 114 | like_sql = like_sql[0..like_sql.length-5] |
| 115 | 115 | ||
| 116 | { | 116 | { |
| 117 | - :joins => [:community], | 117 | + :joins => [:software], |
| 118 | :conditions=>[like_sql, *values] | 118 | :conditions=>[like_sql, *values] |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | + def community | ||
| 123 | + return self.software | ||
| 124 | + end | ||
| 125 | + | ||
| 122 | def license_info | 126 | def license_info |
| 123 | license = LicenseInfo.find_by_id self.license_info_id | 127 | license = LicenseInfo.find_by_id self.license_info_id |
| 124 | license_another = LicenseInfo.find_by_version("Another") | 128 | license_another = LicenseInfo.find_by_version("Another") |
| @@ -145,7 +149,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -145,7 +149,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 145 | end | 149 | end |
| 146 | 150 | ||
| 147 | def validate_name_lenght | 151 | def validate_name_lenght |
| 148 | - if self.community.name.size > 100 | 152 | + if self.software.name.size > 100 |
| 149 | self.errors.add( | 153 | self.errors.add( |
| 150 | :base, | 154 | :base, |
| 151 | _("Name is too long (maximum is %{count} characters)") | 155 | _("Name is too long (maximum is %{count} characters)") |
| @@ -181,21 +185,21 @@ class SoftwareInfo < ActiveRecord::Base | @@ -181,21 +185,21 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 181 | else | 185 | else |
| 182 | software_template = Community["software"] | 186 | software_template = Community["software"] |
| 183 | 187 | ||
| 184 | - community_hash = {:name => name} | ||
| 185 | - community_hash[:identifier] = identifier | ||
| 186 | - community_hash[:image_builder] = image_builder if image_builder | 188 | + software_hash = {:name => name} |
| 189 | + software_hash[:identifier] = identifier | ||
| 190 | + software_hash[:image_builder] = image_builder if image_builder | ||
| 187 | 191 | ||
| 188 | - community = Community.new(community_hash) | ||
| 189 | - community.environment = environment | 192 | + software = Software.new(software_hash) |
| 193 | + software.environment = environment | ||
| 190 | 194 | ||
| 191 | if (!software_template.blank? && software_template.is_template) | 195 | if (!software_template.blank? && software_template.is_template) |
| 192 | - community.template_id = software_template.id | 196 | + software.template_id = software_template.id |
| 193 | end | 197 | end |
| 194 | 198 | ||
| 195 | - community.save! | ||
| 196 | - community.add_admin(requestor) | 199 | + software.save! |
| 200 | + software.add_admin(requestor) | ||
| 197 | 201 | ||
| 198 | - software_info.community = community | 202 | + software_info.software = software |
| 199 | software_info.license_info = license_info | 203 | software_info.license_info = license_info |
| 200 | software_info.verify_license_info(another_license_version, another_license_link) | 204 | software_info.verify_license_info(another_license_version, another_license_link) |
| 201 | software_info.save! | 205 | software_info.save! |
| @@ -247,18 +251,18 @@ class SoftwareInfo < ActiveRecord::Base | @@ -247,18 +251,18 @@ class SoftwareInfo < ActiveRecord::Base | ||
| 247 | end | 251 | end |
| 248 | 252 | ||
| 249 | def visible? | 253 | def visible? |
| 250 | - self.community.visible? | 254 | + self.software.visible? |
| 251 | end | 255 | end |
| 252 | 256 | ||
| 253 | def name | 257 | def name |
| 254 | - self.community.name | 258 | + self.software.name |
| 255 | end | 259 | end |
| 256 | 260 | ||
| 257 | def short_name | 261 | def short_name |
| 258 | - self.community.short_name | 262 | + self.software.short_name |
| 259 | end | 263 | end |
| 260 | 264 | ||
| 261 | def identifier | 265 | def identifier |
| 262 | - self.community.identifier | 266 | + self.software.identifier |
| 263 | end | 267 | end |
| 264 | end | 268 | end |
src/noosfero-spb/software_communities/lib/software_info2.rb
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +class SispInfo < ActiveRecord::Base | ||
| 2 | + | ||
| 3 | + attr_accessible :agency_identification, :softawre_requirements, :hardware_requirements, :documentation, | ||
| 4 | + :system_applications, :active_versions, :estimated_cost, :responsible, :sotware_identification, | ||
| 5 | + :responsible_for_acquirement, :system_info, :development_info, :maintenance, :standards_adherence, :plataform | ||
| 6 | + | ||
| 7 | + belongs_to :sisp | ||
| 8 | + | ||
| 9 | +end |