Mercurial > hg > soundsoftware-site
diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 592:68c6b060385c feature_36
development commit: still users/authors management
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 15 Aug 2011 13:55:01 +0100 |
parents | 9e866f13c984 |
children | 7234e0a90c62 |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Aug 12 16:21:35 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Aug 15 13:55:01 2011 +0100 @@ -20,6 +20,9 @@ @project_id = params[:project_id] @current_user = User.current + + @options = [] + @results = [] end @@ -196,6 +199,8 @@ end def autocomplete_for_author + #TODO: luisf. optimize this Query: possible? + @results = [] authorships_list = Authorship.like(params[:q]).find(:all, :limit => 100) @@ -203,19 +208,30 @@ logger.debug "Query for \"#{params[:q]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users" + authorships_list.each do |authorship| + # NEED TO COMPARE AUTHORSHIPS FOR SIMILAR NAME/INST/EMAIL + @results << authorship + logger.error { "Added AUTHORSHIP #{authorship.id} to the results list" } + end + # need to subtract both lists; give priority to the users + flag = true users_list.each do |user| - @results << user - logger.error { "Added USER #{user.id} to the results list" } - end - - authorships_list.each do |authorship| - unless users_list.include?(authorship.author.user) - @results << authorship - logger.error { "Added AUTHORSHIP #{authorship.id} to the results list" } + if user.author.nil? + @results << user + else + user.author.authorships.each do |auth| + if authorships_list.include?(auth) + flag = false + break + end + end + @results << user unless flag end end +# @results.uniq! + render :layout => false end