From 33a95c7cce5b8ded8f27d370e72ac749ca3bf336 Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Thu, 30 Oct 2014 21:55:40 +0000 Subject: [PATCH] Create software with template --- controllers/mpog_software_plugin_myprofile_controller.rb | 28 +++++++++++++++++----------- views/mpog_software_plugin_myprofile/new_software.html.erb | 2 -- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index 15a7683..e3d0c5f 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -11,6 +11,12 @@ class MpogSoftwarePluginMyprofileController < MyProfileController def new_software @errors = [] + + software_template = Community["software"] + if (!software_template.blank? && software_template.is_template) + params["community"]["template_id"] = software_template.id unless params["community"].blank? + end + @community = Community.new(params[:community]) @community.environment = environment @software_info = SoftwareInfo.new(params[:software_info]) @@ -22,20 +28,20 @@ class MpogSoftwarePluginMyprofileController < MyProfileController valid_community = request.post? && @community.valid? valid_software_info = request.post? && @software_info.valid? valid_license = (request.post? && @license_info.valid?) - if valid_software_info && valid_license && valid_community - @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info ) + if valid_software_info && valid_license && valid_community + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info ) - unless params[:q].nil? - admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} + unless params[:q].nil? + admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} - admins.each do |admin| - @community.add_member(admin) - @community.add_admin(admin) - end - end + admins.each do |admin| + @community.add_member(admin) + @community.add_admin(admin) + end + end - redirect_to :controller => 'profile_editor', :action => 'edit', :profile => @community.identifier - else + redirect_to :controller => 'profile_editor', :action => 'edit', :profile => @community.identifier + else # @list_libraries.each do |lib| # @errors |= lib.errors.full_messages # end diff --git a/views/mpog_software_plugin_myprofile/new_software.html.erb b/views/mpog_software_plugin_myprofile/new_software.html.erb index 5d97909..0eea785 100644 --- a/views/mpog_software_plugin_myprofile/new_software.html.erb +++ b/views/mpog_software_plugin_myprofile/new_software.html.erb @@ -62,8 +62,6 @@ <% end %> - <%= template_options(:communities, 'community')%> - <%= hidden_field_tag('back_to', @back_to) %> <% button_bar do %> -- libgit2 0.21.2