diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index e15bb64..feed657 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -59,6 +59,16 @@ class MpogSoftwarePluginMyprofileController < MyProfileController if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary) + + 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 + redirect_to :controller => 'memberships', :action => 'index' else @list_libraries.each do |lib| @@ -82,4 +92,9 @@ class MpogSoftwarePluginMyprofileController < MyProfileController end end + def search_offerers + arg = params[:q].downcase + result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) + render :text => prepare_to_token_input(result).to_json + end end diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb new file mode 100644 index 0000000..b5ca427 --- /dev/null +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -0,0 +1,30 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + +'/../../controllers/mark_comment_as_read_plugin_profile_controller' + +class MpogSoftwarePluginMyprofileController; def rescue_action(e) raise e end; +end + +class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase + def setup + @controller = MpogSoftwarePluginMyprofileController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + # @organization = Community.create!(:name => 'My Software', :identifier => + # 'my-software') + @person = create_user('person').person + #@organization.add_admin(@person) + login_as(@person.user.login) + e = Environment.default + e.enable_plugin('MpogSoftwarePlugin') + e.save! + end + + attr_accessor :person + + should 'search new offerers while creating a new software' do + end + + should 'search new offerers while edting a new software' do + end +end diff --git a/views/mpog_software_plugin_myprofile/new_software.html.erb b/views/mpog_software_plugin_myprofile/new_software.html.erb index eeb48a4..39c0bd8 100644 --- a/views/mpog_software_plugin_myprofile/new_software.html.erb +++ b/views/mpog_software_plugin_myprofile/new_software.html.erb @@ -97,7 +97,13 @@ <%= swf.text_field(:demonstration_url) %> <% end %> - + +
+ <%= content_tag('label', _('Fill in the search field to add offerers for this Software'), :id => "text-input-search-offerers") %> + <%= token_input_field_tag(:q, 'search-offerers', {:action => 'search_offerers'}, { :focus => true, :hint_text => _('Type in a search term for a person to be added as +offerers'), :pre_populate => @tokenized_children}) %> +
+

<%= _("Libraries") %>

<%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %> -- libgit2 0.21.2