Mercurial > hg > soundsoftware-site
comparison plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 1440:7465cceb8dfc
Merge from live branch
author | Chris Cannam |
---|---|
date | Fri, 11 Oct 2013 09:34:09 +0100 |
parents | ee598c21c239 |
children | 8d721cac2925 |
comparison
equal
deleted
inserted
replaced
1431:303b9be118d4 | 1440:7465cceb8dfc |
---|---|
80 end | 80 end |
81 | 81 |
82 def edit | 82 def edit |
83 find_project_by_project_id unless params[:project_id].nil? | 83 find_project_by_project_id unless params[:project_id].nil? |
84 | 84 |
85 @edit_view = true; | |
86 @publication = Publication.find(params[:id]) | 85 @publication = Publication.find(params[:id]) |
87 @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type | 86 @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type |
88 | |
89 @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id) | 87 @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id) |
90 end | 88 end |
91 | 89 |
92 def update | 90 def update |
93 @publication = Publication.find(params[:id]) | 91 @publication = Publication.find(params[:id]) |
200 @results = [] | 198 @results = [] |
201 | 199 |
202 object_id = params[:object_id] | 200 object_id = params[:object_id] |
203 @object_name = "publications[authorships_attributes][#{object_id}][search_results]" | 201 @object_name = "publications[authorships_attributes][#{object_id}][search_results]" |
204 | 202 |
205 # cc 20110909 -- revert to like instead of like_unique -- see #289 | 203 # todo: make sure query works with both pgres and mysql ~lf.20131010 |
206 authorships_list = Authorship.like(params[:term]).group('author_id').find(:all, :limit => 100) | 204 authors_list = Author.joins(:authorships).where("LOWER(authorships.name_on_paper) LIKE LOWER(?)", "%#{params[:term]}%").uniq |
207 | |
208 authors_list = authorships_list.collect do |x| x.author end | |
209 | 205 |
210 users_list = User.active.like(params[:term]).find(:all, :limit => 100) | 206 users_list = User.active.like(params[:term]).find(:all, :limit => 100) |
211 | 207 |
212 logger.debug "Query for \"#{params[:term]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users" | 208 logger.debug "Query for \"#{params[:term]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users" |
213 | 209 |