Commit 92cac97486903f0ec0b0f1757c86e5ab75648216
1 parent
e8043011
Exists in
master
and in
5 other branches
verify_tests(BUG): Create software after admin approves
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luiz Matos <luizff.matos@gmail.com>
Showing
2 changed files
with
33 additions
and
13 deletions
Show diff stats
lib/ext/community.rb
@@ -9,23 +9,23 @@ class Community | @@ -9,23 +9,23 @@ class Community | ||
9 | 9 | ||
10 | def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil) | 10 | def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil) |
11 | community = Community.new(attributes) | 11 | community = Community.new(attributes) |
12 | - if community.environment.enabled?('admin_must_approve_new_communities') | ||
13 | - CreateCommunity.create(attributes.merge(:requestor => requestor)) | ||
14 | - else | ||
15 | - community = Community.create(attributes) | ||
16 | 12 | ||
17 | - if not software_info.nil? | ||
18 | - if not license_info.nil? | ||
19 | - software_info.license_info = license_info | ||
20 | - end | ||
21 | - | ||
22 | - if not controlled_vocabulary.nil? | ||
23 | - software_info.controlled_vocabulary = controlled_vocabulary | ||
24 | - end | 13 | + if not software_info.nil? |
14 | + if not license_info.nil? | ||
15 | + software_info.license_info = license_info | ||
16 | + end | ||
25 | 17 | ||
26 | - community.software_info = software_info | 18 | + if not controlled_vocabulary.nil? |
19 | + software_info.controlled_vocabulary = controlled_vocabulary | ||
27 | end | 20 | end |
21 | + software_info.save | ||
22 | + end | ||
28 | 23 | ||
24 | + if community.environment.enabled?('admin_must_approve_new_communities') | ||
25 | + cc = CreateCommunity.create(attributes.merge(:requestor => requestor, :software_info=>software_info)) | ||
26 | + else | ||
27 | + community = Community.create(attributes) | ||
28 | + community.software_info = software_info | ||
29 | community.add_admin(requestor) | 29 | community.add_admin(requestor) |
30 | end | 30 | end |
31 | community | 31 | community |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +require_dependency 'create_community' | ||
2 | + | ||
3 | +class CreateCommunity | ||
4 | + settings_items :software_info | ||
5 | + attr_accessible :software_info, :environment, :name, :closed, :template_id, :requestor, :reject_explanation, :target, :image_builder | ||
6 | + | ||
7 | + def perform | ||
8 | + community = Community.new | ||
9 | + community_data = self.data.reject do |key, value| | ||
10 | + ! DATA_FIELDS.include?(key.to_s) | ||
11 | + end | ||
12 | + | ||
13 | + community.update_attributes(community_data) | ||
14 | + community.image = image if image | ||
15 | + community.environment = self.environment | ||
16 | + community.software_info = self.software_info | ||
17 | + community.save! | ||
18 | + community.add_admin(self.requestor) | ||
19 | + end | ||
20 | +end | ||
0 | \ No newline at end of file | 21 | \ No newline at end of file |