diff --git a/lib/ext/community.rb b/lib/ext/community.rb index 7594568..acbdd6e 100644 --- a/lib/ext/community.rb +++ b/lib/ext/community.rb @@ -9,23 +9,23 @@ class Community def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil) community = Community.new(attributes) - if community.environment.enabled?('admin_must_approve_new_communities') - CreateCommunity.create(attributes.merge(:requestor => requestor)) - else - community = Community.create(attributes) - if not software_info.nil? - if not license_info.nil? - software_info.license_info = license_info - end - - if not controlled_vocabulary.nil? - software_info.controlled_vocabulary = controlled_vocabulary - end + if not software_info.nil? + if not license_info.nil? + software_info.license_info = license_info + end - community.software_info = software_info + if not controlled_vocabulary.nil? + software_info.controlled_vocabulary = controlled_vocabulary end + software_info.save + end + if community.environment.enabled?('admin_must_approve_new_communities') + cc = CreateCommunity.create(attributes.merge(:requestor => requestor, :software_info=>software_info)) + else + community = Community.create(attributes) + community.software_info = software_info community.add_admin(requestor) end community diff --git a/lib/ext/create_community.rb b/lib/ext/create_community.rb new file mode 100644 index 0000000..7896914 --- /dev/null +++ b/lib/ext/create_community.rb @@ -0,0 +1,20 @@ +require_dependency 'create_community' + +class CreateCommunity + settings_items :software_info + attr_accessible :software_info, :environment, :name, :closed, :template_id, :requestor, :reject_explanation, :target, :image_builder + + def perform + community = Community.new + community_data = self.data.reject do |key, value| + ! DATA_FIELDS.include?(key.to_s) + end + + community.update_attributes(community_data) + community.image = image if image + community.environment = self.environment + community.software_info = self.software_info + community.save! + community.add_admin(self.requestor) + end +end \ No newline at end of file -- libgit2 0.21.2