Commit 5fa4fc17dbcfac17886bd4ffadf76019eb8c9d8d

Authored by Luciano Prestes
1 parent 67e7b90d

Change public software form

- Only environment admin can change a generic software to a public software
	- Show Adherent fields only to public software

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
@@ -79,7 +79,11 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController @@ -79,7 +79,11 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
79 @list_operating_systems = @software_info.operating_systems 79 @list_operating_systems = @software_info.operating_systems
80 @software_categories = @software_info.software_categories 80 @software_categories = @software_info.software_categories
81 @software_categories = SoftwareCategories.new if @software_categories.blank? 81 @software_categories = SoftwareCategories.new if @software_categories.blank?
  82 +
  83 + @show_public_software_field = show_public_software_field
  84 +
82 if request.post? 85 if request.post?
  86 + params[:software][:public_software] ||= false
83 @software_info = @profile.software_info 87 @software_info = @profile.software_info
84 @license = LicenseInfo.find(params[:license][:license_infos_id]) 88 @license = LicenseInfo.find(params[:license][:license_infos_id])
85 @software_info.license_info = @license 89 @software_info.license_info = @license
@@ -132,4 +136,8 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController @@ -132,4 +136,8 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
132 end 136 end
133 end 137 end
134 138
  139 + def show_public_software_field
  140 + environment.admins.include?(current_user.person)
  141 + end
  142 +
135 end 143 end
db/migrate/20141103180655_add_public_software_field_validation.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddPublicSoftwareFieldValidation < ActiveRecord::Migration
  2 + def up
  3 + add_column :software_infos, :public_software, :boolean, :default => false
  4 + end
  5 +
  6 + def down
  7 + remove_column :software_infos, :public_software
  8 + end
  9 +end
lib/software_info.rb
1 class SoftwareInfo < ActiveRecord::Base 1 class SoftwareInfo < ActiveRecord::Base
2 - attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id, :finality, :repository_link 2 + attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id, :finality, :repository_link, :public_software
3 3
4 has_many :libraries, :dependent => :destroy 4 has_many :libraries, :dependent => :destroy
5 has_many :software_databases 5 has_many :software_databases
views/mpog_software_plugin_myprofile/_public_software_info.html.erb
1 <h1><%= _('Edit software') %></h1> 1 <h1><%= _('Edit software') %></h1>
2 2
3 <div class="formfieldline"> 3 <div class="formfieldline">
4 - <%= label_tag _("Adherent to e-PING ?") %>  
5 -  
6 - <%= label_tag "e_ping_true", "Yes" %>  
7 - <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%>  
8 - <%= label_tag "e_ping_false", "No"%>  
9 - <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%>  
10 -</div>  
11 -  
12 -<div class="formfieldline">  
13 - <%= label_tag _("Adherent to e-MAG ?") %>  
14 -  
15 - <%= label_tag "e_mag_true", "Yes"%>  
16 - <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%>  
17 - <%= label_tag "e_mag_false", "No"%>  
18 - <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%>  
19 -</div>  
20 -  
21 -<div class="formfieldline">  
22 - <%= label_tag _("Adherent to ICP-Brasil ?") %>  
23 -  
24 - <%= label_tag "icp_brasil_true", "Yes"%>  
25 - <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%>  
26 - <%= label_tag "icp_brasil_false", "No"%>  
27 - <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%>  
28 -</div>  
29 -  
30 -<div class="formfieldline">  
31 - <%= label_tag _("Adherent to e-ARQ ?") %>  
32 -  
33 - <%= label_tag "e_arq_true", "Yes"%>  
34 - <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%>  
35 - <%= label_tag "e_arq_false", "No"%>  
36 - <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%>  
37 -</div>  
38 -  
39 -<div class="formfieldline">  
40 - <%= label_tag _("Internacionalizable ?") %>  
41 -  
42 - <%= label_tag "intern_true", "Yes" %>  
43 - <%= radio_button_tag("software[intern]", true, @software_info.intern)%>  
44 - <%= label_tag "intern_false", "No"%>  
45 - <%= radio_button_tag("software[intern]", false, !@software_info.intern)%>  
46 -</div>  
47 -  
48 -<div class="formfieldline">  
49 - <%= label_tag "operating_platform", _("Operating Platform: ") %> <br /> 4 + <h4> <%= _("Operating Platform") %> </h4>
50 <%= text_area_tag "software[operating_platform]", @software_info.operating_platform, :cols => 40, :rows => 5%> 5 <%= text_area_tag "software[operating_platform]", @software_info.operating_platform, :cols => 40, :rows => 5%>
51 </div> 6 </div>
52 7
53 <div class="formfieldline"> 8 <div class="formfieldline">
54 - <%= label_tag "features", _("Features: ")%><br /> 9 + <h4> <%= _("Features") %> </h4>
55 <%= text_area_tag "software[features]", @software_info.features, :maxlength=>"4000", :cols => 40, :rows => 5%> 10 <%= text_area_tag "software[features]", @software_info.features, :maxlength=>"4000", :cols => 40, :rows => 5%>
56 </div> 11 </div>
57 12
@@ -84,6 +39,60 @@ @@ -84,6 +39,60 @@
84 </div> 39 </div>
85 40
86 <div id = "demonstration_url"> 41 <div id = "demonstration_url">
87 - <%= label_tag(:demonstration_url ,_("Demonstration url:"), :class=>"formlabel") %>  
88 - <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %> 42 + <h4> <%= _("Demonstration url") %> </h4>
  43 + <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %>
  44 +</div>
  45 +
  46 +<div id = "public_software">
  47 + <% if @show_public_software_field %>
  48 + <%= check_box_tag("software[public_software]", "true", @software_info.public_software?) %>
  49 + <%= label_tag _("Public Software"), _("Is a public software") %>
  50 + <% end %>
  51 + <% if @software_info.public_software? %>
  52 + <h4> <%= _("Public Software") %> </h4>
  53 + <div class="formfieldline">
  54 + <%= label_tag _("Adherent to e-PING ?") %>
  55 +
  56 + <%= label_tag "e_ping_true", "Yes" %>
  57 + <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%>
  58 + <%= label_tag "e_ping_false", "No"%>
  59 + <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%>
  60 + </div>
  61 +
  62 + <div class="formfieldline">
  63 + <%= label_tag _("Adherent to e-MAG ?") %>
  64 +
  65 + <%= label_tag "e_mag_true", "Yes"%>
  66 + <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%>
  67 + <%= label_tag "e_mag_false", "No"%>
  68 + <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%>
  69 + </div>
  70 +
  71 + <div class="formfieldline">
  72 + <%= label_tag _("Adherent to ICP-Brasil ?") %>
  73 +
  74 + <%= label_tag "icp_brasil_true", "Yes"%>
  75 + <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%>
  76 + <%= label_tag "icp_brasil_false", "No"%>
  77 + <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%>
  78 + </div>
  79 +
  80 + <div class="formfieldline">
  81 + <%= label_tag _("Adherent to e-ARQ ?") %>
  82 +
  83 + <%= label_tag "e_arq_true", "Yes"%>
  84 + <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%>
  85 + <%= label_tag "e_arq_false", "No"%>
  86 + <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%>
  87 + </div>
  88 +
  89 + <div class="formfieldline">
  90 + <%= label_tag _("Internacionalizable ?") %>
  91 +
  92 + <%= label_tag "intern_true", "Yes" %>
  93 + <%= radio_button_tag("software[intern]", true, @software_info.intern)%>
  94 + <%= label_tag "intern_false", "No"%>
  95 + <%= radio_button_tag("software[intern]", false, !@software_info.intern)%>
  96 + </div>
  97 +<% end %>
89 </div> 98 </div>