Commit 15dc1378fb299307799eb29b7cff73b96aef70e4

Authored by Luciano Prestes
Committed by David Silva
1 parent 30e39dd9

Add another license_info as settings_itens

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
db/migrate/20150209170529_add_settings_field_to_software_info.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddSettingsFieldToSoftwareInfo < ActiveRecord::Migration
  2 + def up
  3 + add_column :software_infos, :settings, :text
  4 + end
  5 +
  6 + def down
  7 + remove_column :software_info, :settings
  8 + end
  9 +end
... ...
lib/software_info.rb
1 1 class SoftwareInfo < ActiveRecord::Base
  2 + acts_as_having_settings :field => :setting
  3 +
2 4 SEARCH_FILTERS = []
3 5 SEARCH_DISPLAYS = %w[full]
4 6  
... ... @@ -34,6 +36,8 @@ class SoftwareInfo &lt; ActiveRecord::Base
34 36  
35 37 validate :validate_acronym
36 38  
  39 + settings_items :another_license_version, :another_license_link
  40 +
37 41 # used on find_by_contents
38 42 scope :like_search, lambda{ |name|
39 43 joins(:community).where(
... ... @@ -62,6 +66,25 @@ class SoftwareInfo &lt; ActiveRecord::Base
62 66 }
63 67 }
64 68  
  69 + def license_info
  70 + license = LicenseInfo.find_by_id self.license_info_id
  71 +
  72 + if license == LicenseInfo.find_by_version("Another")
  73 + LicenseInfo.new(
  74 + :version => self.another_license_version,
  75 + :link => self.another_license_link
  76 + )
  77 + else
  78 + license
  79 + end
  80 + end
  81 +
  82 + def another_license(version, link)
  83 + self.another_license_version = version
  84 + self.another_license_link = link
  85 + self.license_info = LicenseInfo.find_by_version("Another")
  86 + end
  87 +
65 88 def validate_name_lenght
66 89 if self.community.name.size > 100
67 90 self.errors.add(
... ...
public/static/licences.txt
... ... @@ -207,3 +207,6 @@ http://opensource.org/licenses/ZPL-2.0
207 207  
208 208 zlib/libpng license (Zlib)
209 209 http://www.openfoundry.org/en/licenses/36-zliblibpng-license-zliblibpng
  210 +
  211 +Another
  212 +#
210 213 \ No newline at end of file
... ...