Commit d8f78c1653323a05b731ca3df596c051c229fa65

Authored by Luciano Prestes
1 parent d02c2ee7

Move name and image fields from community to software edit page

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
controllers/software_communities_plugin_myprofile_controller.rb
@@ -40,6 +40,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -40,6 +40,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
40 update_software_atributes 40 update_software_atributes
41 41
42 return unless request.post? 42 return unless request.post?
  43 +
43 @software_info = constroy_software 44 @software_info = constroy_software
44 software_info_insert_models.call(@list_libraries, 'libraries') 45 software_info_insert_models.call(@list_libraries, 'libraries')
45 software_info_insert_models.call(@list_languages, 'software_languages') 46 software_info_insert_models.call(@list_languages, 'software_languages')
@@ -48,6 +49,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -48,6 +49,10 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
48 49
49 begin 50 begin
50 @software_info.save! 51 @software_info.save!
  52 +
  53 + @community = @software_info.community
  54 + @community.update_attributes!(params[:community])
  55 +
51 if params[:commit] == _('Save and Configure Community') 56 if params[:commit] == _('Save and Configure Community')
52 redirect_to :controller => 'profile_editor', :action => 'edit' 57 redirect_to :controller => 'profile_editor', :action => 'edit'
53 else 58 else
@@ -155,6 +160,8 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController @@ -155,6 +160,8 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
155 params[:software_info].merge({ 160 params[:software_info].merge({
156 :environment => environment, 161 :environment => environment,
157 :name => params[:community][:name], 162 :name => params[:community][:name],
  163 + :identifier => params[:community][:identifier],
  164 + :image_builder => params[:community][:image_builder],
158 :license_info => @license_info, 165 :license_info => @license_info,
159 :another_license_version => another_license_version, 166 :another_license_version => another_license_version,
160 :another_license_link => another_license_link })) 167 :another_license_link => another_license_link }))
features/public_software_validation.feature
@@ -16,7 +16,7 @@ Feature: edit adherent fields @@ -16,7 +16,7 @@ Feature: edit adherent fields
16 And I press "Save changes" 16 And I press "Save changes"
17 And I go to /myprofile/mpog-admin 17 And I go to /myprofile/mpog-admin
18 And I follow "Create a new software" 18 And I follow "Create a new software"
19 - And I fill in "community_name" with "basic software" 19 + And I fill in "community_name_id" with "basic software"
20 And I fill in "software_info_finality" with "basic software finality" 20 And I fill in "software_info_finality" with "basic software finality"
21 And I press "Create" 21 And I press "Create"
22 22
features/software_registration.feature
@@ -12,7 +12,7 @@ Feature: edit public software information @@ -12,7 +12,7 @@ Feature: edit public software information
12 And I press "Save changes" 12 And I press "Save changes"
13 And I go to /myprofile/mpog-admin 13 And I go to /myprofile/mpog-admin
14 And I follow "Create a new software" 14 And I follow "Create a new software"
15 - And I fill in "community_name" with "basic software" 15 + And I fill in "community_name_id" with "basic software"
16 And I fill in "software_info_finality" with "basic software finality" 16 And I fill in "software_info_finality" with "basic software finality"
17 And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2" 17 And I type in "gp" in autocomplete list "#license_info_version" and I choose "GPL-2"
18 And I press "Create" 18 And I press "Create"
features/step_definitions/software_communities_steps.rb
@@ -131,6 +131,8 @@ Given /^the following softwares$/ do |table| @@ -131,6 +131,8 @@ Given /^the following softwares$/ do |table|
131 software_info.community = Community.create(:name=>item[:name]) 131 software_info.community = Community.create(:name=>item[:name])
132 132
133 software_info.acronym = item[:acronym] if item[:acronym] 133 software_info.acronym = item[:acronym] if item[:acronym]
  134 + software_info.finality = item[:finality] if item[:finality]
  135 + software_info.finality ||= "something"
134 software_info.operating_platform = item[:operating_platform] if item[:operating_platform] 136 software_info.operating_platform = item[:operating_platform] if item[:operating_platform]
135 software_info.objectives = item[:objectives] if item[:objectives] 137 software_info.objectives = item[:objectives] if item[:objectives]
136 software_info.features = item[:features] if item[:features] 138 software_info.features = item[:features] if item[:features]
lib/software_info.rb
@@ -159,6 +159,8 @@ class SoftwareInfo &lt; ActiveRecord::Base @@ -159,6 +159,8 @@ class SoftwareInfo &lt; ActiveRecord::Base
159 def self.create_after_moderation(requestor, attributes = {}) 159 def self.create_after_moderation(requestor, attributes = {})
160 environment = attributes.delete(:environment) 160 environment = attributes.delete(:environment)
161 name = attributes.delete(:name) 161 name = attributes.delete(:name)
  162 + identifier = attributes.delete(:identifier)
  163 + image_builder = attributes.delete(:image_builder)
162 license_info = attributes.delete(:license_info) 164 license_info = attributes.delete(:license_info)
163 another_license_version = attributes.delete(:another_license_version) 165 another_license_version = attributes.delete(:another_license_version)
164 another_license_link = attributes.delete(:another_license_link) 166 another_license_link = attributes.delete(:another_license_link)
@@ -175,7 +177,12 @@ class SoftwareInfo &lt; ActiveRecord::Base @@ -175,7 +177,12 @@ class SoftwareInfo &lt; ActiveRecord::Base
175 ) 177 )
176 else 178 else
177 software_template = Community["software"] 179 software_template = Community["software"]
178 - community = Community.new(:name => name) 180 +
  181 + community_hash = {:name => name}
  182 + community_hash[:identifier] = identifier
  183 + community_hash[:image_builder] = image_builder if image_builder
  184 +
  185 + community = Community.new(community_hash)
179 community.environment = environment 186 community.environment = environment
180 187
181 if (!software_template.blank? && software_template.is_template) 188 if (!software_template.blank? && software_template.is_template)
public/style.css
@@ -528,3 +528,8 @@ div.step-explanation { @@ -528,3 +528,8 @@ div.step-explanation {
528 margin-top: 2px; 528 margin-top: 2px;
529 margin-bottom: 15px; 529 margin-bottom: 15px;
530 } 530 }
  531 +
  532 +div#finality textarea {
  533 + resize: none;
  534 + height: 100px;
  535 +}
test/functional/profile_editor_controller_test.rb
@@ -119,7 +119,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -119,7 +119,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
119 community 119 community
120 end 120 end
121 121
122 - def create_software_info name, finality = "", acronym = "" 122 + def create_software_info name, finality = "something", acronym = ""
123 community = create_community(name) 123 community = create_community(name)
124 software_info = SoftwareInfo.new 124 software_info = SoftwareInfo.new
125 software_info.community = community 125 software_info.community = community
test/functional/software_communities_plugin_myprofile_controller_test.rb
@@ -225,8 +225,8 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC @@ -225,8 +225,8 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC
225 225
226 post( 226 post(
227 :new_software, 227 :new_software,
228 - :community => {:name =>"New Software"},  
229 - :software_info => {:finality => "", :repository_link => ""}, 228 + :community => {:name =>"New Software", :identifier => "new-software"},
  229 + :software_info => {:finality => "something", :repository_link => ""},
230 :license =>{:license_infos_id => LicenseInfo.last.id}, 230 :license =>{:license_infos_id => LicenseInfo.last.id},
231 :profile => @person.identifier 231 :profile => @person.identifier
232 ) 232 )
@@ -243,8 +243,8 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC @@ -243,8 +243,8 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC
243 243
244 post( 244 post(
245 :new_software, 245 :new_software,
246 - :community => { :name =>"New Software" },  
247 - :software_info => { :finality => "", :repository_link => "" }, 246 + :community => { :name => "New Software", :identifier => "new-software" },
  247 + :software_info => { :finality => "something", :repository_link => "" },
248 :license => { :license_infos_id => license_another.id, 248 :license => { :license_infos_id => license_another.id,
249 :version => another_license_version, 249 :version => another_license_version,
250 :link=> another_license_link 250 :link=> another_license_link
test/helpers/plugin_test_helper.rb
@@ -13,14 +13,15 @@ module PluginTestHelper @@ -13,14 +13,15 @@ module PluginTestHelper
13 community 13 community
14 end 14 end
15 15
16 - def create_software_info name, finality = "", acronym = "" 16 + def create_software_info name, finality = "something", acronym = ""
17 community = create_community(name) 17 community = create_community(name)
18 software_info = SoftwareInfo.new 18 software_info = SoftwareInfo.new
19 software_info.community = community 19 software_info.community = community
20 software_info.finality = finality 20 software_info.finality = finality
21 software_info.acronym = acronym 21 software_info.acronym = acronym
22 software_info.public_software = true 22 software_info.public_software = true
23 - software_info.save 23 + software_info.save!
  24 +
24 software_info 25 software_info
25 end 26 end
26 27
test/unit/software_info_validation_test.rb
@@ -40,7 +40,8 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase @@ -40,7 +40,8 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
40 :e_arq => true, 40 :e_arq => true,
41 :operating_platform => true, 41 :operating_platform => true,
42 :objectives => "", 42 :objectives => "",
43 - :features => "" 43 + :features => "",
  44 + :finality => "something"
44 ) 45 )
45 @software_info.software_languages << @software_language 46 @software_info.software_languages << @software_language
46 @software_info.software_databases << @software_database 47 @software_info.software_databases << @software_database
test/unit/software_registration_test.rb
@@ -30,7 +30,8 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase @@ -30,7 +30,8 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase
30 task = CreateSoftware.create!( 30 task = CreateSoftware.create!(
31 :name => "Teste Two", 31 :name => "Teste Two",
32 :requestor => person, 32 :requestor => person,
33 - :environment => @environment 33 + :environment => @environment,
  34 + :finality => "something"
34 ) 35 )
35 36
36 software_count = SoftwareInfo.count 37 software_count = SoftwareInfo.count
views/profile_editor/_software_community.html.erb
@@ -2,8 +2,6 @@ @@ -2,8 +2,6 @@
2 2
3 <%= required_fields_message %> 3 <%= required_fields_message %>
4 4
5 - <%= required f.text_field(:name) %>  
6 -  
7 <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %> 5 <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %>
8 6
9 <% if @environment.enabled?('enable_organization_url_change') %> 7 <% if @environment.enabled?('enable_organization_url_change') %>
views/profile_editor/edit_software_community.html.erb
@@ -21,16 +21,6 @@ @@ -21,16 +21,6 @@
21 21
22 <%= render :partial => 'software_community', :locals => { :f => f } %> 22 <%= render :partial => 'software_community', :locals => { :f => f } %>
23 23
24 - <div id="profile_change_picture_title">  
25 - <h2><%= _('Change picture') %></h2>  
26 - <span><%= unchangeable_privacy_field @profile %></span>  
27 - </div>  
28 - <div id="profile_change_picture">  
29 - <%= f.fields_for :image_builder, @profile.image do |i| %>  
30 - <%= file_field_or_thumbnail(_('Image:'), @profile.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %>  
31 - <% end %>  
32 - </div>  
33 -  
34 <h2><%= _('Privacy options') %></h2> 24 <h2><%= _('Privacy options') %></h2>
35 25
36 <% if profile.person? %> 26 <% if profile.person? %>
views/software_communities_plugin_myprofile/_license_info_fields.html.erb
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> 2 <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>">
3 <% end %> 3 <% end %>
4 4
5 -<h3><%= _("License Version: ") %></h3>  
6 <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %> 5 <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %>
7 <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %> 6 <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %>
8 7
views/software_communities_plugin_myprofile/_main_software_editor_extras.html.erb
1 <h1><%= @profile.software_info.name + _(' Information') %></h1> 1 <h1><%= @profile.software_info.name + _(' Information') %></h1>
2 2
  3 +<h3> <%= _("Name") %> </h3>
  4 +<div id="name">
  5 + <%= text_field_tag("community[name]", @profile.name) %>
  6 +</div>
  7 +
3 <h3> <%= _("Acronym") %> </h3> 8 <h3> <%= _("Acronym") %> </h3>
4 <div id="acronym"> 9 <div id="acronym">
5 <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :maxlength=>"10") %> 10 <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :maxlength=>"10") %>
@@ -7,9 +12,19 @@ @@ -7,9 +12,19 @@
7 12
8 <h3> <%= _("Finality") %> </h3> 13 <h3> <%= _("Finality") %> </h3>
9 <div id="finality"> 14 <div id="finality">
10 - <%= text_area_tag "software[finality]", @profile.software_info.finality, :placeholder => _("It is a software of..."), :cols => 40, :rows => 5, :maxlength => 140%> 15 + <%= text_area_tag "software[finality]", @profile.software_info.finality, :placeholder => _("What is the software for?"), :maxlength => 120 %>
  16 +</div>
  17 +
  18 +<div id="profile_change_picture_title">
  19 + <h3><%= _('Software Logo') %></h3>
  20 +</div>
  21 +<div id="profile_change_picture">
  22 + <%= f.fields_for :image_builder, @profile.image do |i| %>
  23 + <%= file_field_or_thumbnail(_('Image:'), @profile.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %>
  24 + <% end %>
11 </div> 25 </div>
12 26
  27 +<h3><%= _("License Version: ") %></h3>
13 <div id='licenses'> 28 <div id='licenses'>
14 <%= render :partial => "license_info_fields", :locals => { 29 <%= render :partial => "license_info_fields", :locals => {
15 :license_version => @license_version, 30 :license_version => @license_version,
@@ -25,3 +40,4 @@ @@ -25,3 +40,4 @@
25 <%= text_field_tag("software[repository_link]", @profile.software_info.repository_link, :class => "improve_input_size") %> 40 <%= text_field_tag("software[repository_link]", @profile.software_info.repository_link, :class => "improve_input_size") %>
26 </div> 41 </div>
27 42
  43 +
views/software_communities_plugin_myprofile/edit_software.html.erb
1 <% tabs = [] %> 1 <% tabs = [] %>
2 2
3 -<%= error_messages_for :software_info %> 3 +<%= error_messages_for :software_info, :community %>
4 4
5 -<%= labelled_form_for :software_communities_plugin_myprofile, :html => { :multipart => true, :id => 'edit-form' } do |f| %> 5 +<%= labelled_form_for :community, :html => { :multipart => true, :id => 'edit-form' } do |f| %>
6 6
7 -<% tabs << {:title => _("Software"), :id => 'basic-info',  
8 - :content => (render :partial => 'main_software_editor_extras')} %> 7 + <% tabs << {:title => _("Software"), :id => 'basic-info',
  8 + :content => (render :partial => 'main_software_editor_extras', :locals => {:f => f})} %>
9 9
10 -<% tabs << {:title => _("Specifications"), :id => 'especific-info',  
11 - :content => (render :partial => 'public_software_info')} %> 10 + <% tabs << {:title => _("Specifications"), :id => 'especific-info',
  11 + :content => (render :partial => 'public_software_info')} %>
12 12
13 -<%= render_tabs(tabs) %> 13 + <%= render_tabs(tabs) %>
14 14
15 -<% button_bar do %> 15 + <% button_bar do %>
16 <%= submit_button(:save, _('Save')) %> 16 <%= submit_button(:save, _('Save')) %>
17 <%= submit_button(:save, _('Save and Configure Community')) %> 17 <%= submit_button(:save, _('Save and Configure Community')) %>
18 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> 18 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %>
19 -<% end %> 19 + <% end %>
20 <% end %> 20 <% end %>
views/software_communities_plugin_myprofile/new_software.html.erb
@@ -43,23 +43,37 @@ @@ -43,23 +43,37 @@
43 <div id='software-name-field' class='formfield'> 43 <div id='software-name-field' class='formfield'>
44 44
45 <span id='software-hostname'><%= environment.default_hostname %>/</span> 45 <span id='software-hostname'><%= environment.default_hostname %>/</span>
46 - <%= required text_field(:community, :name, :size => 30, :maxlength => 100) %> 46 + <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100) %>
47 </div> 47 </div>
48 48
49 <%= fields_for @software_info do |swf| %> 49 <%= fields_for @software_info do |swf| %>
50 - <div class="formfield type-text"> 50 + <div id="finality" class="formfield type-text">
51 <%= swf.label("finality" ,_("Finality"), :class=>"formlabel") %> 51 <%= swf.label("finality" ,_("Finality"), :class=>"formlabel") %>
52 - <%= required swf.text_area(:finality, :placeholder => _("What is the software?"), :cols => 40, :rows => 5, :maxlength => 140) %> 52 + <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %>
53 </div> 53 </div>
54 <% end %> 54 <% end %>
55 55
56 - <div class="formfieldline">  
57 - <%= render :partial => "license_info_fields", :locals => {  
58 - :license_version => "",  
59 - :license_id => "",  
60 - :another_version=>"",  
61 - :another_link=>""  
62 - } %> 56 + <div id="profile_change_picture_title" class="formlabel">
  57 + <label>
  58 + <%= _('Software Logo') %>
  59 + </label>
  60 + </div>
  61 + <div id="profile_change_picture">
  62 + <%= f.fields_for :image_builder, @community.image do |i| %>
  63 + <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %>
  64 + <% end %>
  65 + </div>
  66 +
  67 + <div id="profile_change_picture_title" class="formlabel formfieldline">
  68 + <label>
  69 + <%= _("License Version: ") %>
  70 + </label>
  71 + <%= render :partial => "license_info_fields", :locals => {
  72 + :license_version => "",
  73 + :license_id => "",
  74 + :another_version=>"",
  75 + :another_link=>""
  76 + } %>
63 </div> 77 </div>
64 78
65 <%= fields_for @software_info do |swf| %> 79 <%= fields_for @software_info do |swf| %>