Commit 33a95c7cce5b8ded8f27d370e72ac749ca3bf336
1 parent
ad98cab3
Exists in
master
and in
79 other branches
Create software with template
Showing
2 changed files
with
17 additions
and
13 deletions
Show diff stats
controllers/mpog_software_plugin_myprofile_controller.rb
... | ... | @@ -11,6 +11,12 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
11 | 11 | |
12 | 12 | def new_software |
13 | 13 | @errors = [] |
14 | + | |
15 | + software_template = Community["software"] | |
16 | + if (!software_template.blank? && software_template.is_template) | |
17 | + params["community"]["template_id"] = software_template.id unless params["community"].blank? | |
18 | + end | |
19 | + | |
14 | 20 | @community = Community.new(params[:community]) |
15 | 21 | @community.environment = environment |
16 | 22 | @software_info = SoftwareInfo.new(params[:software_info]) |
... | ... | @@ -22,20 +28,20 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
22 | 28 | valid_community = request.post? && @community.valid? |
23 | 29 | valid_software_info = request.post? && @software_info.valid? |
24 | 30 | valid_license = (request.post? && @license_info.valid?) |
25 | - if valid_software_info && valid_license && valid_community | |
26 | - @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info ) | |
31 | + if valid_software_info && valid_license && valid_community | |
32 | + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info ) | |
27 | 33 | |
28 | - unless params[:q].nil? | |
29 | - admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
34 | + unless params[:q].nil? | |
35 | + admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
30 | 36 | |
31 | - admins.each do |admin| | |
32 | - @community.add_member(admin) | |
33 | - @community.add_admin(admin) | |
34 | - end | |
35 | - end | |
37 | + admins.each do |admin| | |
38 | + @community.add_member(admin) | |
39 | + @community.add_admin(admin) | |
40 | + end | |
41 | + end | |
36 | 42 | |
37 | - redirect_to :controller => 'profile_editor', :action => 'edit', :profile => @community.identifier | |
38 | - else | |
43 | + redirect_to :controller => 'profile_editor', :action => 'edit', :profile => @community.identifier | |
44 | + else | |
39 | 45 | # @list_libraries.each do |lib| |
40 | 46 | # @errors |= lib.errors.full_messages |
41 | 47 | # end | ... | ... |
views/mpog_software_plugin_myprofile/new_software.html.erb