Mercurial > hg > soundsoftware-site
changeset 1113:ca871a83c0f4 bibplugin_bibtex
creates the author in case it no suggestion was made by the user.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 11 Dec 2012 18:48:33 +0000 |
parents | 70849df4eae1 |
children | 212b72b966ff |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Dec 11 16:49:41 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Dec 11 18:48:33 2012 +0000 @@ -96,7 +96,6 @@ def create_from_bibtex find_project_by_project_id - # todo: drop unknown parameters from params hash lf.07122012 @publication = Publication.new(:title => params[:pub][:title]) @publication.build_bibtex_entry(params[:pub][:bibtex_entry]) @publication.projects << @project unless @project.nil? @@ -106,8 +105,12 @@ authorship = Authorship.new :name_on_paper => auth[:name_on_paper] - unless auth[:parent].nil? - logger.error { "AUTH PRENT #{auth[:parent]}" } + # when there's no association at all + if auth[:parent].nil? + logger.error { "Creating new author (no assoc)" } + author = Author.new + else + logger.error { "AUTH PARENT #{auth[:parent]}" } parent_class, parent_id = auth[:parent].split "_" if parent_class == "user" @@ -116,13 +119,12 @@ else author = Author.find(parent_id) end - - authorship.author_id = author.id end - # todo: test success + authorship.author_id = author.id authorship.save! + @pubication.authors << author @publication.authorships << authorship end @@ -256,6 +258,7 @@ logger.error { "Suggest Authors: Found #{authorships.count} Authorships " } suggested_authors = [] + # todo. should be careful with nil author_ids suggested_authors = authorships.map { |a| a.author } unless authorships.empty? suggested_authors.uniq! unless suggested_authors.empty?
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Tue Dec 11 16:49:41 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Tue Dec 11 18:48:33 2012 +0000 @@ -7,6 +7,7 @@ <br /> <%- suggestions[1][:authors].each do |auth| -%> + <%= create_author_suggestion_radio("pub[authorships][#{index}][parent]", auth) -%> <%- end -%> <br />