Commit 56b6ebc30a37579ea09dd6103eb0c243d7c51633

Authored by Fabio Teixeira
1 parent 90eb5f31
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

find_offerer: Add tokenized to find new offerers for software

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
controllers/mpog_software_plugin_myprofile_controller.rb
@@ -59,6 +59,16 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController @@ -59,6 +59,16 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
59 59
60 if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system 60 if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system
61 @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary) 61 @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary)
  62 +
  63 + unless params[:q].nil?
  64 + admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i}
  65 +
  66 + admins.each do |admin|
  67 + @community.add_member(admin)
  68 + @community.add_admin(admin)
  69 + end
  70 + end
  71 +
62 redirect_to :controller => 'memberships', :action => 'index' 72 redirect_to :controller => 'memberships', :action => 'index'
63 else 73 else
64 @list_libraries.each do |lib| 74 @list_libraries.each do |lib|
@@ -82,4 +92,9 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController @@ -82,4 +92,9 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
82 end 92 end
83 end 93 end
84 94
  95 + def search_offerers
  96 + arg = params[:q].downcase
  97 + result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"])
  98 + render :text => prepare_to_token_input(result).to_json
  99 + end
85 end 100 end
test/functional/mpog_software_plugin_myprofile_controller_test.rb 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) +
  3 +'/../../controllers/mark_comment_as_read_plugin_profile_controller'
  4 +
  5 +class MpogSoftwarePluginMyprofileController; def rescue_action(e) raise e end;
  6 +end
  7 +
  8 +class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase
  9 + def setup
  10 + @controller = MpogSoftwarePluginMyprofileController.new
  11 + @request = ActionController::TestRequest.new
  12 + @response = ActionController::TestResponse.new
  13 + # @organization = Community.create!(:name => 'My Software', :identifier =>
  14 + # 'my-software')
  15 + @person = create_user('person').person
  16 + #@organization.add_admin(@person)
  17 + login_as(@person.user.login)
  18 + e = Environment.default
  19 + e.enable_plugin('MpogSoftwarePlugin')
  20 + e.save!
  21 + end
  22 +
  23 + attr_accessor :person
  24 +
  25 + should 'search new offerers while creating a new software' do
  26 + end
  27 +
  28 + should 'search new offerers while edting a new software' do
  29 + end
  30 +end
views/mpog_software_plugin_myprofile/new_software.html.erb
@@ -97,7 +97,13 @@ @@ -97,7 +97,13 @@
97 <%= swf.text_field(:demonstration_url) %> 97 <%= swf.text_field(:demonstration_url) %>
98 </div> 98 </div>
99 <% end %> 99 <% end %>
100 - 100 +
  101 + <div class="formfieldline">
  102 + <%= content_tag('label', _('Fill in the search field to add offerers for this Software'), :id => "text-input-search-offerers") %>
  103 + <%= 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
  104 +offerers'), :pre_populate => @tokenized_children}) %>
  105 + </div>
  106 +
101 <div id='libraries_fields'> 107 <div id='libraries_fields'>
102 <h4> <%= _("Libraries") %> </h4> 108 <h4> <%= _("Libraries") %> </h4>
103 <%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %> 109 <%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %>