Commit e45cbbf7a5131039e7bbb7d5e6740dee58af8d79

Authored by Gabriela Navarro
Committed by Fabio Teixeira
1 parent 8936e302

Edit specific software information

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
... ... @@ -66,48 +66,63 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
66 66 end
67 67  
68 68 def edit_software
69   -
70   - @list_libraries = LibraryHelper.list_libraries(params[:library])
71   - @list_languages = SoftwareLanguageHelper.list_language(params[:language])
72   - @list_databases = DatabaseHelper.list_database(params[:database])
73   - @software_categories = SoftwareCategories::new params[:software_categories]
74   - @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system])
75   -
76   -
77   - if not @list_libraries.nil?
78   - @list_libraries.each do |library|
79   - @software_info.libraries << library
  69 + @software_info = @profile.software_info
  70 + @list_libraries = @software_info.libraries
  71 + @list_databases = @software_info.software_databases
  72 + @list_languages = @software_info.software_languages
  73 + @list_operating_systems = @software_info.operating_systems
  74 + @software_categories = @software_info.software_categories
  75 + @software_categories = SoftwareCategories.new if @software_categories.blank?
  76 + if request.post?
  77 + @software_info = SoftwareInfo.find(Community.where(:name => params[:name]).first.software_info.id)
  78 + @license = LicenseInfo.find(params[:license][:license_infos_id])
  79 + @software_info.license_info = @license
  80 + @software_info.update_attributes(params[:software])
  81 +
  82 + @list_libraries = LibraryHelper.list_libraries(params[:library])
  83 + @list_languages = SoftwareLanguageHelper.list_language(params[:language])
  84 + @list_databases = DatabaseHelper.list_database(params[:database])
  85 + @software_categories = SoftwareCategories::new params[:software_categories]
  86 + @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system])
  87 +
  88 + @software_info.software_categories = @software_categories
  89 +
  90 + if not @list_libraries.nil?
  91 + @software_info.libraries.destroy_all
  92 + @list_libraries.each do |library|
  93 + @software_info.libraries << library
  94 + end
80 95 end
81   - end
82 96  
83   - if not @list_languages.nil?
84   - @list_languages.each do |language|
85   - @software_info.software_languages << language
  97 + if not @list_languages.nil?
  98 + @software_info.software_languages.destroy_all
  99 + @list_languages.each do |language|
  100 + @software_info.software_languages << language
  101 + end
86 102 end
87   - end
88 103  
89   - if not @list_databases.nil?
90   - @list_databases.each do |database|
91   - @software_info.software_databases << database
  104 + if not @list_databases.nil?
  105 + @software_info.software_databases.destroy_all
  106 + @list_databases.each do |database|
  107 + @software_info.software_databases << database
  108 + end
92 109 end
93   - end
94 110  
95   - if not @list_operating_systems.nil?
96   - @list_operating_systems.each do |operating_system|
97   - @software_info.operating_systems << operating_system
  111 + if not @list_operating_systems.nil?
  112 + @software_info.operating_systems.destroy_all
  113 + @list_operating_systems.each do |operating_system|
  114 + @software_info.operating_systems << operating_system
  115 + end
98 116 end
99   - end
100 117  
101   - valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries)
102   - valid_database = DatabaseHelper.valid_list_database?(@list_databases)
103   - valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages)
104   - valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems)
105   - valid_software_categories = request.post? && @software_categories.valid?
  118 + valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries)
  119 + valid_database = DatabaseHelper.valid_list_database?(@list_databases)
  120 + valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages)
  121 + valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems)
  122 + valid_software_categories = request.post? && @software_categories.valid?
106 123  
107   - if request.post?
108   - #@software_info.update_attributes(params[:software])
109   - #@software_info.save!
  124 + @software_info.save!
110 125 end
111 126 end
112 127  
113   -end
114 128 \ No newline at end of file
  129 +end
... ...
db/migrate/20141013193939_add_repository_link_to_software.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddRepositoryLinkToSoftware < ActiveRecord::Migration
  2 + def up
  3 + add_column :software_infos, :repository_link, :string
  4 + end
  5 +
  6 + def down
  7 + remove_column :software_infos, :repository_link
  8 + end
  9 +end
... ...
lib/software_info.rb
1 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
3   - attr_accessible :finality
  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
4 3  
5 4 has_many :libraries, :dependent => :destroy
6 5 has_many :software_databases
... ...
views/mpog_software_plugin_myprofile/_main_software_editor_extras.html.erb
... ... @@ -14,7 +14,7 @@
14 14  
15 15 <h3> <%= _("Licenses") %> </h3>
16 16 <div id='licenses'>
17   - <%= select_tag(:version, options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => @profile.software_info.license_info.id), :onchange => "get_license_link('version')") %>
  17 + <%= select_tag("license[license_infos_id]", options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => @profile.software_info.license_info.id), :onchange => "get_license_link('version')") %>
18 18 <br />
19 19  
20 20 <h4> <%= _("License link") %> </h4>
... ... @@ -27,6 +27,6 @@
27 27  
28 28 <div class="formfieldline formfield type-text">
29 29 <%= label_tag "repository_url", _("Link to Repository: ") %>
30   - <%= text_field_tag(:reository_url) %>
  30 + <%= text_field_tag("software[repository_link]", @profile.software_info.repository_link) %>
31 31 </div>
32 32  
... ...
views/mpog_software_plugin_myprofile/_public_software_info.html.erb
1 1 <h1><%= _('Edit software') %></h1>
2 2  
3 3 <div class="formfield type-text">
4   - <%= label_tag("acronym" ,_("Acronym"), :class=>"formlabel") %>
5   - <%= text_field_tag(:acronym) %>
  4 + <%= label_tag(:acronym ,_("Acronym"), :class=>"formlabel") %>
  5 + <%= text_field_tag("software[acronym]", @software_info.acronym) %>
6 6 </div>
7 7  
8 8 <div class="formfieldline">
9 9 <%= label_tag _("Adherent to e-PING ?") %>
10 10  
11 11 <%= label_tag "e_ping_true", "Yes" %>
12   - <%= radio_button_tag(:e_ping,true)%>
  12 + <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%>
13 13 <%= label_tag "e_ping_false", "No"%>
14   - <%= radio_button_tag(:e_ping,false)%>
  14 + <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%>
15 15 </div>
16 16  
17 17 <div class="formfieldline">
18 18 <%= label_tag _("Adherent to e-MAG ?") %>
19 19  
20 20 <%= label_tag "e_mag_true", "Yes"%>
21   - <%= radio_button_tag(:e_mag,true)%>
  21 + <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%>
22 22 <%= label_tag "e_mag_false", "No"%>
23   - <%= radio_button_tag(:e_mag,false)%>
  23 + <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%>
24 24 </div>
25 25  
26 26 <div class="formfieldline">
27 27 <%= label_tag _("Adherent to ICP-Brasil ?") %>
28 28  
29 29 <%= label_tag "icp_brasil_true", "Yes"%>
30   - <%= radio_button_tag(:icp_brasil,true)%>
  30 + <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%>
31 31 <%= label_tag "icp_brasil_false", "No"%>
32   - <%= radio_button_tag(:icp_brasil,false)%>
  32 + <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%>
33 33 </div>
34 34  
35 35 <div class="formfieldline">
36 36 <%= label_tag _("Adherent to e-ARQ ?") %>
37 37  
38 38 <%= label_tag "e_arq_true", "Yes"%>
39   - <%= radio_button_tag(:e_arq,true)%>
  39 + <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%>
40 40 <%= label_tag "e_arq_false", "No"%>
41   - <%= radio_button_tag(:e_arq,false)%>
  41 + <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%>
42 42 </div>
43 43  
44 44 <div class="formfieldline">
45 45 <%= label_tag _("Internacionalizable ?") %>
46 46  
47 47 <%= label_tag "intern_true", "Yes" %>
48   - <%= radio_button_tag(:intern,true)%>
  48 + <%= radio_button_tag("software[intern]", true, @software_info.intern)%>
49 49 <%= label_tag "intern_false", "No"%>
50   - <%= radio_button_tag(:intern,false)%>
  50 + <%= radio_button_tag("software[intern]", false, !@software_info.intern)%>
51 51 <div class="formfieldline">
52 52 <%= label_tag "operating_platform", _("Operating Platform: ") %> <br />
53   - <%= text_area_tag :operating_platform %>
  53 + <%= text_area_tag "software[operating_platform]", @software_info.operating_platform %>
54 54 </div>
55 55  
56 56 <div class="formfieldline">
57 57 <%= label_tag "objectives", _("Objectives: ")%><br />
58   - <%= text_area_tag :objectives %>
  58 + <%= text_area_tag "software[objectives]", @software_info.objectives%>
59 59 </div>
60 60  
61 61 <div class="formfieldline">
62 62 <%= label_tag "features", _("Features: ")%><br />
63   - <%= text_area_tag :features %>
  63 + <%= text_area_tag "software[features]", @software_info.features %>
64 64 </div>
65 65  
66 66 <div id='libraries_fields'>
... ... @@ -94,69 +94,12 @@
94 94 <div id="software_categories_fields">
95 95 <h4> <%= _("Software Categories:") %> </h4>
96 96  
97   - <%= check_box_tag :administration %>
98   - <%= label_tag :administration, _("Administration") %><br />
  97 + <% @software_categories.attributes.each do |k, v| %>
  98 + <% if not k == "id" and not k == "software_info_id" %>
  99 + <%= check_box_tag "software_categories[#{k}]", "true", !v.blank? %>
  100 + <%= label_tag k.to_sym, _("#{k.gsub("_", " ").capitalize}") %><br />
  101 + <% puts "="*80, v%>
  102 + <% end %>
  103 + <% end %>
99 104  
100   - <%= check_box_tag :agriculture %>
101   - <%= label_tag :agriculture, _("Agriculture") %><br />
102   -
103   - <%= check_box_tag :business_and_services %>
104   - <%= label_tag :business_and_services, _("Business_and Services") %><br />
105   -
106   - <%= check_box_tag :communication %>
107   - <%= label_tag :communication, _("Communication") %><br />
108   -
109   - <%= check_box_tag :culture %>
110   - <%= label_tag :culture, _("Culture") %><br />
111   -
112   - <%= check_box_tag :national_defense %>
113   - <%= label_tag :national_defense, _("National Defense") %><br />
114   -
115   - <%= check_box_tag :economy_and_finances %>
116   - <%= label_tag :economy_and_finances, _("Economy and Finances") %><br />
117   -
118   - <%= check_box_tag :education %>
119   - <%= label_tag :education, _("Education") %><br />
120   -
121   - <%= check_box_tag :energy %>
122   - <%= label_tag :energy, _("Energy") %><br />
123   -
124   - <%= check_box_tag :sports %>
125   - <%= label_tag :sports, _("Sports") %><br />
126   -
127   - <%= check_box_tag :habitation %>
128   - <%= label_tag :habitation, _("Habitation") %><br />
129   -
130   - <%= check_box_tag :industry %>
131   - <%= label_tag :industry, _("Industry") %><br />
132   -
133   - <%= check_box_tag :environment %>
134   - <%= label_tag :environment, _("Environment") %><br />
135   -
136   - <%= check_box_tag :research_and_development %>
137   - <%= label_tag :research_and_development, _("Research and Development") %><br />
138   -
139   - <%= check_box_tag :social_security %>
140   - <%= label_tag :social_security, _("Social Security") %><br />
141   -
142   - <%= check_box_tag :social_protection %>
143   - <%= label_tag :social_protection, _("Social Protection") %><br />
144   -
145   - <%= check_box_tag :sanitation %>
146   - <%= label_tag :sanitation, _("Sanitation") %><br />
147   -
148   - <%= check_box_tag :health %>
149   - <%= label_tag :health, _("Health") %><br />
150   -
151   - <%= check_box_tag :security_public_order %>
152   - <%= label_tag :security_public_order, _("Security and Public Order") %><br />
153   -
154   - <%= check_box_tag :work %>
155   - <%= label_tag :work, _("Work") %><br />
156   -
157   - <%= check_box_tag :transportation %>
158   - <%= label_tag :transportation, _("Transportation") %><br />
159   -
160   - <%= check_box_tag :urbanism %>
161   - <%= label_tag :urbanism, _("Urbanism") %><br />
162   -</div>
163 105 \ No newline at end of file
  106 +</div>
... ...