# HG changeset patch # User luisf # Date 1312562657 -3600 # Node ID 82a6e37563832756e9e596174abb868c044d461d # Parent 9d786d8d3b1f764916a56e3ca93c1ebd2d5d00a6 Some changes to the way the author/users are added to a publication. Not finished. diff -r 9d786d8d3b1f -r 82a6e3756383 vendor/plugins/redmine_bibliography/app/models/authorship.rb --- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Thu Aug 04 17:00:13 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Fri Aug 05 17:44:17 2011 +0100 @@ -1,4 +1,6 @@ class Authorship < ActiveRecord::Base + unloadable + belongs_to :author belongs_to :publication @@ -11,17 +13,22 @@ end def user_id=(uid) - unless uid.blank? + if uid.blank? + author = Author.new :name => self.name_on_paper + author.save! + self.author_id = author.id + else user = User.find(uid) + if user.author.nil? # TODO: should reflect the name_on_paper parameter - author = Author.new :name => user.name + author = Author.new :name => self.name_on_paper author.save! user.author = author user.save! - end - - self.author_id = user.author.id + else + self.author_id = user.author.id + end end end end