Commit 0d4a8d9838dadcbf6b54fb058fc04c6be71ee4f7
Committed by
Daniela Feitosa
1 parent
86d9f952
Exists in
refactor_software_communities
Refactor software_communities.
Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
16 changed files
with
120 additions
and
134 deletions
Show diff stats
src/noosfero-spb/software_communities/controllers/software_communities_plugin_controller.rb
@@ -5,11 +5,9 @@ class SoftwareCommunitiesPluginController < ApplicationController | @@ -5,11 +5,9 @@ class SoftwareCommunitiesPluginController < ApplicationController | ||
5 | def get_license_data | 5 | def get_license_data |
6 | return render :json=>{} if !request.xhr? || params[:query].nil? | 6 | return render :json=>{} if !request.xhr? || params[:query].nil? |
7 | 7 | ||
8 | - data = if params[:query].empty? | ||
9 | - LicenseInfo.all | ||
10 | - else | ||
11 | - LicenseInfo.where("version ILIKE ?", "%#{params[:query]}%").select("id, version") | ||
12 | - end | 8 | + data = LicenseHelper.find_licenses(params[:query]) if params[:query] |
9 | + data ||= LicenseInfo.all | ||
10 | + | ||
13 | render :json=> data.collect { |license| | 11 | render :json=> data.collect { |license| |
14 | {:id=>license.id, :label=>license.version} | 12 | {:id=>license.id, :label=>license.version} |
15 | } | 13 | } |
@@ -44,11 +42,7 @@ class SoftwareCommunitiesPluginController < ApplicationController | @@ -44,11 +42,7 @@ class SoftwareCommunitiesPluginController < ApplicationController | ||
44 | protected | 42 | protected |
45 | 43 | ||
46 | def get_model_by_params_field | 44 | def get_model_by_params_field |
47 | - case params[:field] | ||
48 | - when "software_language" | ||
49 | - return ProgrammingLanguage | ||
50 | - else | ||
51 | - return DatabaseDescription | ||
52 | - end | 45 | + return DatabaseDescription unless params[:field] == "software_language" |
46 | + return ProgrammingLanguage | ||
53 | end | 47 | end |
54 | end | 48 | end |
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
@@ -9,16 +9,16 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -9,16 +9,16 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
9 | 9 | ||
10 | @community = Community.new(params[:community]) | 10 | @community = Community.new(params[:community]) |
11 | @community.environment = environment | 11 | @community.environment = environment |
12 | - @software_info = SoftwareInfo.new(params[:software_info]) | ||
13 | 12 | ||
14 | - @license_info = if params[:license].blank? or params[:license][:license_infos_id].blank? | ||
15 | - LicenseInfo.new | ||
16 | - else | ||
17 | - LicenseInfo.find(params[:license][:license_infos_id]) | ||
18 | - end | 13 | + @license_info = LicenseInfo.find_by_id(params[:license][:license_infos_id]) if params[:license] |
14 | + @license_info ||= LicenseInfo.new | ||
15 | + | ||
16 | + @software_info = SoftwareInfo.new(params[:software_info]) | ||
17 | + @software_info.community = @community | ||
18 | + @software_info.license_info = @license_info | ||
19 | 19 | ||
20 | control_software_creation | 20 | control_software_creation |
21 | - update_new_software_errors | 21 | + update_software_highlight_errors |
22 | end | 22 | end |
23 | 23 | ||
24 | def edit_software | 24 | def edit_software |
@@ -26,7 +26,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -26,7 +26,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
26 | 26 | ||
27 | return unless request.post? | 27 | return unless request.post? |
28 | 28 | ||
29 | - @software_info = constroy_software | 29 | + @software_info = create_software |
30 | software_info_insert_models.call(@list_libraries, 'libraries') | 30 | software_info_insert_models.call(@list_libraries, 'libraries') |
31 | software_info_insert_models.call(@list_languages, 'software_languages') | 31 | software_info_insert_models.call(@list_languages, 'software_languages') |
32 | software_info_insert_models.call(@list_databases, 'software_databases') | 32 | software_info_insert_models.call(@list_databases, 'software_databases') |
@@ -45,7 +45,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -45,7 +45,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
45 | session[:notice] = _('Software updated successfully') | 45 | session[:notice] = _('Software updated successfully') |
46 | end | 46 | end |
47 | rescue ActiveRecord::RecordInvalid => invalid | 47 | rescue ActiveRecord::RecordInvalid => invalid |
48 | - update_new_software_errors | 48 | + update_software_highlight_errors |
49 | session[:notice] = _('Could not update software') | 49 | session[:notice] = _('Could not update software') |
50 | end | 50 | end |
51 | end | 51 | end |
@@ -58,17 +58,25 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -58,17 +58,25 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
58 | 58 | ||
59 | def add_software_erros | 59 | def add_software_erros |
60 | @errors = [] | 60 | @errors = [] |
61 | - @errors |= @community.errors.full_messages if @community | 61 | + if @community |
62 | + error = @community.errors.delete(:identifier) | ||
63 | + @errors |= [_("Domain %s") % error.first ] if error | ||
64 | + @errors |= @community.errors.full_messages | ||
65 | + end | ||
62 | @errors |= @software_info.errors.full_messages if @software_info | 66 | @errors |= @software_info.errors.full_messages if @software_info |
63 | @errors |= @license_info.errors.full_messages if @license_info | 67 | @errors |= @license_info.errors.full_messages if @license_info |
64 | end | 68 | end |
65 | 69 | ||
66 | def control_software_creation | 70 | def control_software_creation |
67 | - valid_models = request.post? && (@community.valid? && @software_info.valid? && @license_info.valid?) | ||
68 | - if valid_models | ||
69 | - send_software_to_moderation | ||
70 | - else | ||
71 | - add_software_erros | 71 | + if request.post? |
72 | + valid_models = @community.valid? | ||
73 | + valid_models &= @software_info.valid? | ||
74 | + valid_models &= @license_info.valid? | ||
75 | + if valid_models | ||
76 | + send_software_to_moderation | ||
77 | + else | ||
78 | + add_software_erros | ||
79 | + end | ||
72 | end | 80 | end |
73 | end | 81 | end |
74 | 82 | ||
@@ -79,7 +87,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -79,7 +87,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
79 | } | 87 | } |
80 | end | 88 | end |
81 | 89 | ||
82 | - def constroy_software | 90 | + def create_software |
83 | @software_info = @profile.software_info | 91 | @software_info = @profile.software_info |
84 | params[:software][:public_software] ||= false unless @software_info.public_software? | 92 | params[:software][:public_software] ||= false unless @software_info.public_software? |
85 | @license = LicenseInfo.find(params[:license][:license_infos_id]) | 93 | @license = LicenseInfo.find(params[:license][:license_infos_id]) |
@@ -126,7 +134,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -126,7 +134,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
126 | 134 | ||
127 | add_admin_to_community | 135 | add_admin_to_community |
128 | 136 | ||
129 | - if !environment.admins.include?(current_user.person) | 137 | + if !environment.admins.include?(current_user.person) |
130 | session[:notice] = _('Your new software request will be evaluated by an'\ | 138 | session[:notice] = _('Your new software request will be evaluated by an'\ |
131 | 'administrator. You will be notified.') | 139 | 'administrator. You will be notified.') |
132 | redirect_to user.admin_url | 140 | redirect_to user.admin_url |
@@ -176,15 +184,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | @@ -176,15 +184,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController | ||
176 | end | 184 | end |
177 | end | 185 | end |
178 | 186 | ||
179 | - def update_new_software_errors | ||
180 | - if request.post? | ||
181 | - @community.valid? if @community | ||
182 | - @software_info.valid? if @software_info | ||
183 | - @license_info.valid? if @license_info | ||
184 | - add_software_erros | ||
185 | - end | ||
186 | - | ||
187 | - | 187 | + def update_software_highlight_errors |
188 | @error_community_name = @community.errors.include?(:name) ? "highlight-error" : "" if @community | 188 | @error_community_name = @community.errors.include?(:name) ? "highlight-error" : "" if @community |
189 | @error_software_acronym = @software_info.errors.include?(:acronym) ? "highlight-error" : "" if @software_info | 189 | @error_software_acronym = @software_info.errors.include?(:acronym) ? "highlight-error" : "" if @software_info |
190 | @error_software_domain = @community.errors.include?(:identifier) ? "highlight-error" : "" if @community | 190 | @error_software_domain = @community.errors.include?(:identifier) ? "highlight-error" : "" if @community |
src/noosfero-spb/software_communities/lib/create_software.rb
@@ -5,12 +5,12 @@ class CreateSoftware < Task | @@ -5,12 +5,12 @@ class CreateSoftware < Task | ||
5 | validates_presence_of :name | 5 | validates_presence_of :name |
6 | 6 | ||
7 | attr_accessible :name, :finality, :repository_link, :requestor, :environment, | 7 | attr_accessible :name, :finality, :repository_link, :requestor, :environment, |
8 | - :reject_explanation, :license_info | 8 | + :reject_explanation, :license_info, :identifier |
9 | 9 | ||
10 | alias :environment :target | 10 | alias :environment :target |
11 | alias :environment= :target= | 11 | alias :environment= :target= |
12 | 12 | ||
13 | - DATA_FIELDS = ['name', 'finality', 'license_info', 'repository_link'] | 13 | + DATA_FIELDS = ['name', 'identifier', 'finality', 'license_info', 'repository_link'] |
14 | DATA_FIELDS.each do |field| | 14 | DATA_FIELDS.each do |field| |
15 | settings_items field.to_sym | 15 | settings_items field.to_sym |
16 | end | 16 | end |
@@ -21,7 +21,11 @@ class CreateSoftware < Task | @@ -21,7 +21,11 @@ class CreateSoftware < Task | ||
21 | template_id = software_template.id | 21 | template_id = software_template.id |
22 | end | 22 | end |
23 | 23 | ||
24 | + identifier = self.identifier | ||
25 | + identifier ||= self.name.to_slug | ||
26 | + | ||
24 | community = Community.create!(:name => self.name, | 27 | community = Community.create!(:name => self.name, |
28 | + :identifier => identifier, | ||
25 | :template_id => template_id) | 29 | :template_id => template_id) |
26 | 30 | ||
27 | community.environment = self.environment | 31 | community.environment = self.environment |
src/noosfero-spb/software_communities/lib/database_helper.rb
@@ -34,12 +34,7 @@ class DatabaseHelper < DynamicTableHelper | @@ -34,12 +34,7 @@ class DatabaseHelper < DynamicTableHelper | ||
34 | 34 | ||
35 | def self.valid_list_database? list_databases | 35 | def self.valid_list_database? list_databases |
36 | return false if list_databases.nil? or list_databases.length == 0 | 36 | return false if list_databases.nil? or list_databases.length == 0 |
37 | - | ||
38 | - list_databases.each do |database| | ||
39 | - return false unless database.valid? | ||
40 | - end | ||
41 | - | ||
42 | - true | 37 | + return !list_databases.any?{|database| !database.valid?} |
43 | end | 38 | end |
44 | 39 | ||
45 | def self.database_as_tables(list_databases, disabled=false) | 40 | def self.database_as_tables(list_databases, disabled=false) |
@@ -51,14 +46,10 @@ class DatabaseHelper < DynamicTableHelper | @@ -51,14 +46,10 @@ class DatabaseHelper < DynamicTableHelper | ||
51 | 46 | ||
52 | def self.database_html_structure(database_data, disabled) | 47 | def self.database_html_structure(database_data, disabled) |
53 | database_id = database_data[:database_description_id] | 48 | database_id = database_data[:database_description_id] |
54 | - database_name = if database_data[:database_description_id].blank? | ||
55 | - "" | ||
56 | - else | ||
57 | - DatabaseDescription.find( | 49 | + database_name = database_id.blank? ? "" : DatabaseDescription.find( |
58 | database_data[:database_description_id], | 50 | database_data[:database_description_id], |
59 | :select=>"name" | 51 | :select=>"name" |
60 | ).name | 52 | ).name |
61 | - end | ||
62 | 53 | ||
63 | data = { | 54 | data = { |
64 | model_name: MODEL_NAME, | 55 | model_name: MODEL_NAME, |
@@ -83,4 +74,4 @@ class DatabaseHelper < DynamicTableHelper | @@ -83,4 +74,4 @@ class DatabaseHelper < DynamicTableHelper | ||
83 | def self.add_dynamic_table | 74 | def self.add_dynamic_table |
84 | database_as_tables(nil).first.call | 75 | database_as_tables(nil).first.call |
85 | end | 76 | end |
86 | -end | ||
87 | \ No newline at end of file | 77 | \ No newline at end of file |
78 | +end |
src/noosfero-spb/software_communities/lib/library_helper.rb
@@ -20,12 +20,7 @@ class LibraryHelper < DynamicTableHelper | @@ -20,12 +20,7 @@ class LibraryHelper < DynamicTableHelper | ||
20 | 20 | ||
21 | def self.valid_list_library? list_libraries | 21 | def self.valid_list_library? list_libraries |
22 | return true if list_libraries.nil? or list_libraries.length == 0 | 22 | return true if list_libraries.nil? or list_libraries.length == 0 |
23 | - | ||
24 | - list_libraries.each do |library| | ||
25 | - return false unless library.valid? | ||
26 | - end | ||
27 | - | ||
28 | - true | 23 | + return !list_libraries.any?{|library| !library.valid?} |
29 | end | 24 | end |
30 | 25 | ||
31 | def self.libraries_as_tables list_libraries, disabled=false | 26 | def self.libraries_as_tables list_libraries, disabled=false |
@@ -59,4 +54,4 @@ class LibraryHelper < DynamicTableHelper | @@ -59,4 +54,4 @@ class LibraryHelper < DynamicTableHelper | ||
59 | def self.add_dynamic_table | 54 | def self.add_dynamic_table |
60 | libraries_as_tables(nil).first.call | 55 | libraries_as_tables(nil).first.call |
61 | end | 56 | end |
62 | -end | ||
63 | \ No newline at end of file | 57 | \ No newline at end of file |
58 | +end |
src/noosfero-spb/software_communities/lib/license_helper.rb
1 | module LicenseHelper | 1 | module LicenseHelper |
2 | - def self.getListLicenses | ||
3 | - LicenseInfo.all | 2 | + def self.find_licenses query |
3 | + licenses = LicenseInfo.where("version ILIKE ?", "%#{query}%").select("id, version") | ||
4 | + licenses.reject!{|license| license.version == "Another"} | ||
5 | + license_another = LicenseInfo.find_by_version("Another") | ||
6 | + licenses << license_another if license_another | ||
7 | + licenses | ||
4 | end | 8 | end |
5 | -end | ||
6 | \ No newline at end of file | 9 | \ No newline at end of file |
10 | +end |
src/noosfero-spb/software_communities/lib/operating_system_helper.rb
@@ -25,12 +25,8 @@ class OperatingSystemHelper < DynamicTableHelper | @@ -25,12 +25,8 @@ class OperatingSystemHelper < DynamicTableHelper | ||
25 | end | 25 | end |
26 | 26 | ||
27 | def self.valid_list_operating_system? list_operating_system | 27 | def self.valid_list_operating_system? list_operating_system |
28 | - return !(list_operating_system.nil? || list_operating_system.length == 0) | ||
29 | - | ||
30 | - list_operating_system.each do |operating_system| | ||
31 | - return false unless operating_system.valid? | ||
32 | - end | ||
33 | - true | 28 | + return false if (list_operating_system.nil? || list_operating_system.length == 0) |
29 | + return !list_operating_system.any?{|os| !os.valid?} | ||
34 | end | 30 | end |
35 | 31 | ||
36 | def self.operating_system_as_tables(list_operating_system, disabled=false) | 32 | def self.operating_system_as_tables(list_operating_system, disabled=false) |
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
@@ -18,8 +18,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -18,8 +18,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
18 | end | 18 | end |
19 | 19 | ||
20 | def profile_tabs | 20 | def profile_tabs |
21 | - if context.profile.community? | ||
22 | - return profile_tabs_software if context.profile.software? | 21 | + if context.profile.community? && context.profile.software? |
22 | + return profile_tabs_software | ||
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
@@ -102,7 +102,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -102,7 +102,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
102 | is_admin ||= user_rating.organization.admins.include?(current_user.person) | 102 | is_admin ||= user_rating.organization.admins.include?(current_user.person) |
103 | 103 | ||
104 | if is_admin and profile.software? | 104 | if is_admin and profile.software? |
105 | - | ||
106 | render :file => 'organization_ratings_extra_fields_show_data', | 105 | render :file => 'organization_ratings_extra_fields_show_data', |
107 | :locals => {:user_rating => user_rating} | 106 | :locals => {:user_rating => user_rating} |
108 | end | 107 | end |
src/noosfero-spb/software_communities/lib/software_helper.rb
@@ -23,22 +23,6 @@ module SoftwareHelper | @@ -23,22 +23,6 @@ module SoftwareHelper | ||
23 | end | 23 | end |
24 | 24 | ||
25 | def self.all_table_is_empty? table, ignored_fields=[] | 25 | def self.all_table_is_empty? table, ignored_fields=[] |
26 | - filled_fields = [] | ||
27 | - | ||
28 | - table.each do |key, value| | ||
29 | - unless ignored_fields.include? key | ||
30 | - filled_fields << if value.empty? | ||
31 | - false | ||
32 | - else | ||
33 | - true | ||
34 | - end | ||
35 | - end | ||
36 | - end | ||
37 | - | ||
38 | - if filled_fields.include? true | ||
39 | - false | ||
40 | - else | ||
41 | - true | ||
42 | - end | 26 | + return !table.keys.any?{|key| ignored_fields.include?(key) ? false : !table[key].empty?} |
43 | end | 27 | end |
44 | end | 28 | end |
src/noosfero-spb/software_communities/lib/software_info.rb
@@ -84,7 +84,7 @@ class SoftwareInfo < ActiveRecord::Base | @@ -84,7 +84,7 @@ class SoftwareInfo < ActiveRecord::Base | ||
84 | validates_length_of :finality, :maximum => 120 | 84 | validates_length_of :finality, :maximum => 120 |
85 | validates_length_of :objectives, :maximum => 4000 | 85 | validates_length_of :objectives, :maximum => 4000 |
86 | validates_length_of :features, :maximum => 4000 | 86 | validates_length_of :features, :maximum => 4000 |
87 | - validates_presence_of :finality | 87 | + validates_presence_of :finality, :community |
88 | 88 | ||
89 | validate :validate_acronym | 89 | validate :validate_acronym |
90 | 90 | ||
@@ -166,12 +166,13 @@ class SoftwareInfo < ActiveRecord::Base | @@ -166,12 +166,13 @@ class SoftwareInfo < ActiveRecord::Base | ||
166 | another_license_link = attributes.delete(:another_license_link) | 166 | another_license_link = attributes.delete(:another_license_link) |
167 | 167 | ||
168 | software_info = SoftwareInfo.new(attributes) | 168 | software_info = SoftwareInfo.new(attributes) |
169 | - if !environment.admins.include? requestor | 169 | + unless environment.admins.include? requestor |
170 | CreateSoftware.create!( | 170 | CreateSoftware.create!( |
171 | attributes.merge( | 171 | attributes.merge( |
172 | :requestor => requestor, | 172 | :requestor => requestor, |
173 | :environment => environment, | 173 | :environment => environment, |
174 | :name => name, | 174 | :name => name, |
175 | + :identifier => identifier, | ||
175 | :license_info => license_info | 176 | :license_info => license_info |
176 | ) | 177 | ) |
177 | ) | 178 | ) |
@@ -189,15 +190,16 @@ class SoftwareInfo < ActiveRecord::Base | @@ -189,15 +190,16 @@ class SoftwareInfo < ActiveRecord::Base | ||
189 | community.template_id = software_template.id | 190 | community.template_id = software_template.id |
190 | end | 191 | end |
191 | 192 | ||
192 | - software_info.license_info = license_info | ||
193 | - software_info.save | ||
194 | - community.software_info = software_info | ||
195 | community.save! | 193 | community.save! |
196 | community.add_admin(requestor) | 194 | community.add_admin(requestor) |
195 | + | ||
196 | + software_info.community = community | ||
197 | + software_info.license_info = license_info | ||
198 | + software_info.save! | ||
197 | end | 199 | end |
198 | 200 | ||
199 | software_info.verify_license_info(another_license_version, another_license_link) | 201 | software_info.verify_license_info(another_license_version, another_license_link) |
200 | - software_info.save! | 202 | + software_info.save |
201 | software_info | 203 | software_info |
202 | end | 204 | end |
203 | 205 |
src/noosfero-spb/software_communities/lib/software_language_helper.rb
@@ -50,10 +50,9 @@ class SoftwareLanguageHelper < DynamicTableHelper | @@ -50,10 +50,9 @@ class SoftwareLanguageHelper < DynamicTableHelper | ||
50 | 50 | ||
51 | def self.language_html_structure(language_data, disabled) | 51 | def self.language_html_structure(language_data, disabled) |
52 | language_id = language_data[:programming_language_id] | 52 | language_id = language_data[:programming_language_id] |
53 | - language_name = if language_data[:programming_language_id].blank? | ||
54 | - "" | ||
55 | - else | ||
56 | - ProgrammingLanguage.find( | 53 | + language_name = "" |
54 | + unless language_data[:programming_language_id].blank? | ||
55 | + language_name = ProgrammingLanguage.find( | ||
57 | language_data[:programming_language_id], | 56 | language_data[:programming_language_id], |
58 | :select=>"name" | 57 | :select=>"name" |
59 | ).name | 58 | ).name |
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb
@@ -151,4 +151,57 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | @@ -151,4 +151,57 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | ||
151 | assert_equal SoftwareInfo.last.license_info.version, another_license_version | 151 | assert_equal SoftwareInfo.last.license_info.version, another_license_version |
152 | assert_equal SoftwareInfo.last.license_info.link, another_license_link | 152 | assert_equal SoftwareInfo.last.license_info.link, another_license_link |
153 | end | 153 | end |
154 | + | ||
155 | + should "show error messages on create software_info" do | ||
156 | + post( | ||
157 | + :new_software, | ||
158 | + :community => {}, | ||
159 | + :software_info => {}, | ||
160 | + :license => {}, | ||
161 | + :profile => @person.identifier | ||
162 | + ) | ||
163 | + assert_includes @response.body, "Domain can't be blank" | ||
164 | + assert_includes @response.body, "Name can't be blank" | ||
165 | + assert_includes @response.body, "Finality can't be blank" | ||
166 | + assert_includes @response.body, "Version can't be blank" | ||
167 | + end | ||
168 | + | ||
169 | + should "show domain not available error" do | ||
170 | + @environment.add_admin(@person) | ||
171 | + | ||
172 | + post( | ||
173 | + :new_software, | ||
174 | + :community => {:name =>"New Software", :identifier => "new-software"}, | ||
175 | + :software_info => {:finality => "something", :repository_link => ""}, | ||
176 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | ||
177 | + :profile => @person.identifier | ||
178 | + ) | ||
179 | + post( | ||
180 | + :new_software, | ||
181 | + :community => {:name =>"New Software", :identifier => "new-software"}, | ||
182 | + :software_info => {:finality => "something", :repository_link => ""}, | ||
183 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | ||
184 | + :profile => @person.identifier | ||
185 | + ) | ||
186 | + | ||
187 | + assert_includes @response.body, "Domain is not available" | ||
188 | + end | ||
189 | + | ||
190 | + should "create software with admin moderation" do | ||
191 | + @environment.enable('admin_must_approve_new_communities') | ||
192 | + | ||
193 | + post( | ||
194 | + :new_software, | ||
195 | + :community => {:name =>"New Software", :identifier => "new-software"}, | ||
196 | + :software_info => {:finality => "something", :repository_link => ""}, | ||
197 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | ||
198 | + :profile => @person.identifier | ||
199 | + ) | ||
200 | + | ||
201 | + @environment.add_admin(@person) | ||
202 | + Task.last.send('finish', @person) | ||
203 | + | ||
204 | + assert_equal "New Software", Task.last.data[:name] | ||
205 | + assert_equal "New Software", SoftwareInfo.last.community.name | ||
206 | + end | ||
154 | end | 207 | end |
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
@@ -49,6 +49,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -49,6 +49,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
49 | 49 | ||
50 | @software_info.features = "Do a lot of things" | 50 | @software_info.features = "Do a lot of things" |
51 | @software_info.objectives = "All tests should pass !" | 51 | @software_info.objectives = "All tests should pass !" |
52 | + @software_info.community = @community | ||
52 | end | 53 | end |
53 | 54 | ||
54 | def teardown | 55 | def teardown |
src/noosfero-spb/software_communities/views/_main_software_editor_extras.html.erb
@@ -1,32 +0,0 @@ | @@ -1,32 +0,0 @@ | ||
1 | -<h2><%= _('Software Information') %></h2> | ||
2 | - | ||
3 | -<%= label_tag("name", _('Name'), {:class => 'formlabel'}) %> | ||
4 | - | ||
5 | -<div id='software-name-field' class='formfield'> | ||
6 | - <span id='software-hostname'><%= context.profile.environment.default_hostname %>/</span> | ||
7 | - <%= text_field_tag(:name, context.profile.software_info.community.name) %> | ||
8 | -</div> | ||
9 | - | ||
10 | -<h3> <%= _("Finality") %> </h3> | ||
11 | -<div id="finality"> | ||
12 | - <%= text_field_tag(:finality, context.profile.software_info.finality) %> | ||
13 | -</div> | ||
14 | - | ||
15 | -<h3> <%= _("Licenses") %> </h3> | ||
16 | -<div id='licenses'> | ||
17 | - <%= select_tag(:id, options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => context.profile.software_info.license_info.id), :onchange => "get_license_link('version')") %> | ||
18 | - <br /> | ||
19 | - | ||
20 | - <h4> <%= _("License link") %> </h4> | ||
21 | - <% LicenseHelper.getListLicenses.each do | license | %> | ||
22 | - <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> | ||
23 | - <% end %> | ||
24 | - | ||
25 | - <a id = "version_link" href="<%= context.profile.software_info.license_info.link %>" target="BLANK"> <%= context.profile.software_info.license_info.link %> </a> | ||
26 | -</div> | ||
27 | - | ||
28 | -<div class="formfieldline formfield type-text"> | ||
29 | - <%= label_tag "repository_url", _("Link to Repository: ") %> | ||
30 | - <%= text_field_tag(:reository_url) %> | ||
31 | -</div> | ||
32 | - |
src/noosfero-spb/software_communities/views/software_communities_plugin_myprofile/_license_info_fields.html.erb
1 | -<% LicenseHelper.getListLicenses.each do | license | %> | ||
2 | - <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> | ||
3 | -<% end %> | ||
4 | - | ||
5 | <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %> | 1 | <%= text_field_tag "license_info[version]", license_version, :id=>"license_info_version", :class=>"license_info_version", :placeholder=>_('Autocomplete field, type some license') %> |
6 | <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %> | 2 | <%= hidden_field_tag "license[license_infos_id]", license_id, :id=>"license_info_id", :class=>"license_info_id", :data => {:label=>license_version} %> |
7 | 3 |
src/noosfero-spb/software_communities/views/software_communities_plugin_myprofile/_main_software_editor_extras.html.erb
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | </div> | 5 | </div> |
6 | 6 | ||
7 | <div class= <%= @error_software_acronym %> > | 7 | <div class= <%= @error_software_acronym %> > |
8 | - <%= label_tag("software[acronym]", _('Short Name'), {:class => 'formlabel mandatory'}) %> | 8 | + <%= label_tag("software[acronym]", _('Short Name'), {:class => 'formlabel'}) %> |
9 | <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :id => 'software_acronym_id', :maxlength=>"10") %> | 9 | <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :id => 'software_acronym_id', :maxlength=>"10") %> |
10 | </div> | 10 | </div> |
11 | 11 |