Mercurial > hg > soundsoftware-site
changeset 1112:70849df4eae1 bibplugin_bibtex
Adds attribute accessors to the bibtex_entry model in order to silently ignore unknown parameters; fixes association between authors/users/authorships.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 11 Dec 2012 16:49:41 +0000 |
parents | 7d62d2f497c5 |
children | ca871a83c0f4 |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb |
diffstat | 3 files changed, 15 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Dec 07 14:39:38 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Dec 11 16:49:41 2012 +0000 @@ -93,7 +93,6 @@ end end - def create_from_bibtex find_project_by_project_id @@ -102,30 +101,25 @@ @publication.build_bibtex_entry(params[:pub][:bibtex_entry]) @publication.projects << @project unless @project.nil? - params[:pub][:authorships].each do |idx| auth = idx[1] authorship = Authorship.new :name_on_paper => auth[:name_on_paper] unless auth[:parent].nil? - if auth[:parent] > -1 - logger.error { "AUTH PRENT #{auth[:parent]}" } - parent_class, parent_id = auth[:parent].split "_" + logger.error { "AUTH PRENT #{auth[:parent]}" } + parent_class, parent_id = auth[:parent].split "_" - if parent_class == "user" - user = User.find(id) - author = user.author ||= Author.create(:name => auth[:name_on_paper]) - else - author = Author.find(id) - end + if parent_class == "user" + user = User.find(parent_id) + author = user.author ||= Author.create(:name => auth[:name_on_paper]) + else + author = Author.find(parent_id) + end - authorship.author_id = author.id - end + authorship.author_id = author.id end - - # todo: test success authorship.save!
--- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Fri Dec 07 14:39:38 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Tue Dec 11 16:49:41 2012 +0000 @@ -3,14 +3,16 @@ belongs_to :publication validates_presence_of :entry_type - + + attr_accessible :entry_type, :address, :annote, :booktitle, :chapter, :crossref, :edition, :editor, :eprint, :howpublished, :journal, :key, :month, :note, :number, :organization, :pages, :publisher, :school, :series, :type, :url, :volume, :year + def entry_type_name entry_type = self.entry_type BibtexEntryType.find(entry_type).name end - + def entry_type_label entry_type = self.entry_type BibtexEntryType.find(entry_type).label - end + end end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Fri Dec 07 14:39:38 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Tue Dec 11 16:49:41 2012 +0000 @@ -13,7 +13,7 @@ <%- suggestions[1][:users].each do |usr| -%> <%= create_user_suggestion_radio("pub[authorship][#{index}][parent]", usr) -%> <%- end -%> - <%= radio_button_tag("pub][authorship][#{index}][parent]", "-1", false) -%><%= l(:none_of_above) %> + <%= radio_button_tag("pub][authorship][#{index}][parent]", nil, false) -%><%= l(:none_of_above) %> <br /> </p> <%- end -%>