diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 480:19efecf4561a feature_36

new controller logic.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 30 Jun 2011 18:19:52 +0100
parents 7be2c5d9ffa5
children cc267eb99115
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Jun 30 12:54:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Jun 30 18:19:52 2011 +0100
@@ -10,10 +10,10 @@
     @publication = Publication.new      
     
     # we'll always want a new publication to have its bibtex entry
-    @publication.build_bibtex_entry
+    # @publication.build_bibtex_entry
     
     # and at least one author
-    @publication.authorships.build.build_author
+    # @publication.authorships.build.build_author
     
     @project_id = params[:project_id]
     @current_user = User.current
@@ -212,8 +212,20 @@
   end
 
   def autocomplete_for_author
-    @authors = Author.like(params[:q]).find(:all, :limit => 100)
-    logger.debug "Query for \"#{params[:q]}\" returned \"#{@authors.size}\" results"
+    @authors = []
+    
+    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}\""
+    
+    # need to subtract both lists
+    # give priority to the users
+    
+    authors_list.each do |author|
+      @authors << author unless author.user_id.nil?
+    end
+                
     render :layout => false
   end