Commit 15dc1378fb299307799eb29b7cff73b96aef70e4
Committed by
David Silva
1 parent
30e39dd9
Exists in
master
and in
5 other branches
Add another license_info as settings_itens
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
3 changed files
with
35 additions
and
0 deletions
Show diff stats
db/migrate/20150209170529_add_settings_field_to_software_info.rb
0 → 100644
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 < 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 < 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