# HG changeset patch # User luisf # Date 1312382479 -3600 # Node ID ca9e8e562ea7abf0be1f958a130fac3f0881bcf0 # Parent dd4c04e5756ddf6137d1deee188f3675643971e0 Addresses Bug #177: when the publication is saved the authors are saved in the order they were entered. *Attention*: need to re-migrate (and re-seed) the plugin's database! diff -r dd4c04e5756d -r ca9e8e562ea7 vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Aug 03 15:16:41 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Aug 03 15:41:19 2011 +0100 @@ -16,4 +16,22 @@ has_and_belongs_to_many :projects, :uniq => true + after_save :set_initial_author_order + + def set_initial_author_order + authorships = self.authorships + + logger.debug { "Publication \"#{self.title}\" has #{authorships.size} authors." } + + authorships.each_with_index do |authorship, index| + if authorship.auth_order.nil? + authorship.auth_order = index + authorship.save! + end + end + end + + + + end diff -r dd4c04e5756d -r ca9e8e562ea7 vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Wed Aug 03 15:16:41 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Wed Aug 03 15:41:19 2011 +0100 @@ -6,7 +6,7 @@

<%= l(:authors) %>