Mercurial > hg > soundsoftware-site
diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 519:3be6bc3c2a17 feature_36
Correctly searches and sends the parameters for both users and authors.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 15 Jul 2011 17:21:05 +0100 |
parents | b24091590b63 |
children | ce1614b19759 |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Jul 14 17:10:24 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jul 15 17:21:05 2011 +0100 @@ -4,8 +4,7 @@ unloadable before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author] - - + def new @publication = Publication.new @@ -17,8 +16,8 @@ @project_id = params[:project_id] @current_user = User.current + end - end def create @publication = Publication.new(params[:publication]) @@ -27,6 +26,9 @@ logger.error { "PARAMS publication" } logger.error { params[:publication] } + # array with the user ids + @users = [] + @publication.projects << @project if @publication.save @@ -196,20 +198,23 @@ end def autocomplete_for_author - @authors = [] + @results = [] authors_list = Author.like(params[:q]).find(:all, :limit => 100) users_list = User.active.like(params[:q]).find(:all, :limit => 100) - logger.debug "Query for \"#{params[:q]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\"" + logger.debug "Query for \"#{params[:q]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users" # need to subtract both lists - # give priority to the users + # give priority to the users + users_list.each do |user| + @results << user + end - authors_list.each do |author| - @authors << author unless author.user_id.nil? + authors_list.each do |author| + @results << author unless users_list.include?(author.user_id) end - + render :layout => false end