From 4a7ff579ee8beb022f583f4bd1c2a823c32158ad Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Thu, 1 Oct 2015 14:17:50 +0200 Subject: [PATCH] Refactor licenses in view of create software --- controllers/software_communities_plugin_myprofile_controller.rb | 6 ++++++ lib/license_helper.rb | 10 ++++++++-- views/software_communities_plugin_myprofile/_license_info_fields.html.erb | 6 +++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/controllers/software_communities_plugin_myprofile_controller.rb b/controllers/software_communities_plugin_myprofile_controller.rb index eda06e2..ddb9680 100644 --- a/controllers/software_communities_plugin_myprofile_controller.rb +++ b/controllers/software_communities_plugin_myprofile_controller.rb @@ -5,6 +5,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController end def new_software + @licenses = LicenseHelper.getListLicenses + @license_another = LicenseHelper.getAnotherLicense + set_software_as_template @community = Community.new(params[:community]) @@ -22,6 +25,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController end def edit_software + @licenses = LicenseHelper.getListLicenses + @license_another = LicenseHelper.getAnotherLicense + update_software_atributes return unless request.post? diff --git a/lib/license_helper.rb b/lib/license_helper.rb index af390cb..58ee898 100644 --- a/lib/license_helper.rb +++ b/lib/license_helper.rb @@ -1,5 +1,11 @@ module LicenseHelper def self.getListLicenses - LicenseInfo.all + licenses = LicenseInfo.select{|license| license.version != "Another"} + licenses end -end \ No newline at end of file + + def self.getAnotherLicense + license_another = LicenseInfo.find_by_version("Another") + license_another + end +end diff --git a/views/software_communities_plugin_myprofile/_license_info_fields.html.erb b/views/software_communities_plugin_myprofile/_license_info_fields.html.erb index 3cde616..abcc0dd 100644 --- a/views/software_communities_plugin_myprofile/_license_info_fields.html.erb +++ b/views/software_communities_plugin_myprofile/_license_info_fields.html.erb @@ -1,7 +1,11 @@ -<% LicenseHelper.getListLicenses.each do | license | %> +<% @licenses.each do | license | %> <% end %> +<% if @license_another %> + " value = "<%=@license_another.link%>"> +<% end %> + <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %> <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %> -- libgit2 0.21.2