Commit 7ecb0945580f9e4a9c374629cf62a8dc4eddf720
1 parent
3ab32308
Exists in
refactor_software_for_sisp
Generalize SoftwareInfo and add sisp software
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
6 changed files
with
86 additions
and
24 deletions
Show diff stats
src/noosfero-spb/software_communities/db/migrate/20151125175514_create_sisp_info.rb
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +class CreateSispInfo < ActiveRecord::Migration | |
2 | + def up | |
3 | + create_table :sisp_infos do |t| | |
4 | + t.integer :sisp_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 :sisp_infos | |
25 | + end | |
26 | +end | ... | ... |
src/noosfero-spb/software_communities/db/migrate/20151125191157_update_software_info.rb
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +class UpdateSoftwareInfo < ActiveRecord::Migration | |
2 | + def up | |
3 | + rename_table :software_infos, :softwares | |
4 | + add_column :softwares, :name , :string | |
5 | + add_column :softwares, :identifier , :string | |
6 | + add_column :softwares, :type , :string, :default => 'SoftwareInfo' | |
7 | + end | |
8 | + | |
9 | + def down | |
10 | + remove_column :softwares, :name | |
11 | + remove_column :softwares, :identifier | |
12 | + remove_column :softwares, :type | |
13 | + rename_table :softwares, :software_infos | |
14 | + end | |
15 | +end | ... | ... |
... | ... | @@ -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 | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +class Software < ActiveRecord::Base | |
2 | + | |
3 | + attr_accessible :acronym, :objectives, :features, :finality, :name, :identifier | |
4 | + | |
5 | + has_one :software_categories | |
6 | + | |
7 | + validates_length_of :finality, :maximum => 120 | |
8 | + validates_length_of :objectives, :maximum => 4000 | |
9 | + validates_length_of :features, :maximum => 4000 | |
10 | + | |
11 | + validate :validate_acronym | |
12 | + validates_presence_of :finality | |
13 | + | |
14 | + def validate_acronym | |
15 | + self.acronym = "" if self.acronym.nil? | |
16 | + if self.acronym.length > 10 && self.errors.messages[:acronym].nil? | |
17 | + self.errors.add(:acronym, _("can't have more than 10 characteres")) | |
18 | + false | |
19 | + elsif self.acronym.match(/\s+/) | |
20 | + self.errors.add(:acronym, _("can't have whitespaces")) | |
21 | + false | |
22 | + end | |
23 | + true | |
24 | + end | |
25 | + | |
26 | +end | ... | ... |
src/noosfero-spb/software_communities/lib/software_info.rb
1 | -class SoftwareInfo < ActiveRecord::Base | |
1 | +class SoftwareInfo < Software | |
2 | 2 | acts_as_having_settings :field => :settings |
3 | 3 | |
4 | 4 | SEARCHABLE_SOFTWARE_FIELDS = { |
... | ... | @@ -62,10 +62,9 @@ class SoftwareInfo < ActiveRecord::Base |
62 | 62 | attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, |
63 | 63 | :operating_platform |
64 | 64 | |
65 | - attr_accessible :demonstration_url, :acronym, :objectives, :features, | |
66 | - :license_info | |
65 | + attr_accessible :demonstration_url, :license_info | |
67 | 66 | |
68 | - attr_accessible :community_id, :finality, :repository_link, :public_software, | |
67 | + attr_accessible :community_id, :repository_link, :public_software, | |
69 | 68 | :first_edit |
70 | 69 | |
71 | 70 | has_many :libraries, :dependent => :destroy |
... | ... | @@ -79,14 +78,8 @@ class SoftwareInfo < ActiveRecord::Base |
79 | 78 | belongs_to :community, :dependent => :destroy |
80 | 79 | belongs_to :license_info |
81 | 80 | |
82 | - has_one :software_categories | |
83 | - | |
81 | + validates_presence_of :community | |
84 | 82 | validates_length_of :finality, :maximum => 120 |
85 | - validates_length_of :objectives, :maximum => 4000 | |
86 | - validates_length_of :features, :maximum => 4000 | |
87 | - validates_presence_of :finality, :community | |
88 | - | |
89 | - validate :validate_acronym | |
90 | 83 | |
91 | 84 | settings_items :another_license_version, :another_license_link |
92 | 85 | |
... | ... | @@ -215,19 +208,6 @@ class SoftwareInfo < ActiveRecord::Base |
215 | 208 | end |
216 | 209 | end |
217 | 210 | |
218 | - | |
219 | - def validate_acronym | |
220 | - self.acronym = "" if self.acronym.nil? | |
221 | - if self.acronym.length > 10 && self.errors.messages[:acronym].nil? | |
222 | - self.errors.add(:acronym, _("can't have more than 10 characteres")) | |
223 | - false | |
224 | - elsif self.acronym.match(/\s+/) | |
225 | - self.errors.add(:acronym, _("can't have whitespaces")) | |
226 | - false | |
227 | - end | |
228 | - true | |
229 | - end | |
230 | - | |
231 | 211 | def valid_operating_systems |
232 | 212 | if self.operating_systems.empty? |
233 | 213 | self.errors.add(:operating_system, _(": at least one must be filled")) | ... | ... |