Commit 4a7ff579ee8beb022f583f4bd1c2a823c32158ad
Committed by
Thiago Ribeiro
1 parent
9769663a
Exists in
refactor_software_info_365
Refactor licenses in view of create software
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
3 changed files
with
19 additions
and
3 deletions
Show diff stats
controllers/software_communities_plugin_myprofile_controller.rb
| ... | ... | @@ -5,6 +5,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
| 5 | 5 | end |
| 6 | 6 | |
| 7 | 7 | def new_software |
| 8 | + @licenses = LicenseHelper.getListLicenses | |
| 9 | + @license_another = LicenseHelper.getAnotherLicense | |
| 10 | + | |
| 8 | 11 | set_software_as_template |
| 9 | 12 | |
| 10 | 13 | @community = Community.new(params[:community]) |
| ... | ... | @@ -22,6 +25,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
| 22 | 25 | end |
| 23 | 26 | |
| 24 | 27 | def edit_software |
| 28 | + @licenses = LicenseHelper.getListLicenses | |
| 29 | + @license_another = LicenseHelper.getAnotherLicense | |
| 30 | + | |
| 25 | 31 | update_software_atributes |
| 26 | 32 | |
| 27 | 33 | return unless request.post? | ... | ... |
lib/license_helper.rb
| 1 | 1 | module LicenseHelper |
| 2 | 2 | def self.getListLicenses |
| 3 | - LicenseInfo.all | |
| 3 | + licenses = LicenseInfo.select{|license| license.version != "Another"} | |
| 4 | + licenses | |
| 4 | 5 | end |
| 5 | -end | |
| 6 | 6 | \ No newline at end of file |
| 7 | + | |
| 8 | + def self.getAnotherLicense | |
| 9 | + license_another = LicenseInfo.find_by_version("Another") | |
| 10 | + license_another | |
| 11 | + end | |
| 12 | +end | ... | ... |
views/software_communities_plugin_myprofile/_license_info_fields.html.erb
| 1 | -<% LicenseHelper.getListLicenses.each do | license | %> | |
| 1 | +<% @licenses.each do | license | %> | |
| 2 | 2 | <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> |
| 3 | 3 | <% end %> |
| 4 | 4 | |
| 5 | +<% if @license_another %> | |
| 6 | + <input type="hidden" id = "version_<%=_("Another") %>" value = "<%=@license_another.link%>"> | |
| 7 | +<% end %> | |
| 8 | + | |
| 5 | 9 | <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %> |
| 6 | 10 | <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %> |
| 7 | 11 | ... | ... |