Mercurial > hg > soundsoftware-site
changeset 556:ca9e8e562ea7 feature_36
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!
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 03 Aug 2011 15:41:19 +0100 |
parents | dd4c04e5756d |
children | 2fe129b04d82 |
files | vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb |
diffstat | 3 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 @@ <h4><%= l(:authors) %></h4> <ul id="authorships"> - <% for authorship in @publication.authorships %> + <% for authorship in @publication.authorships.find(:all, :order => :auth_order) %> <% content_tag_for :li, authorship do %> <%= h authorship.name_on_paper %> <br /> <%= h authorship.institution %> <br />
--- a/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Wed Aug 03 15:16:41 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Wed Aug 03 15:41:19 2011 +0100 @@ -4,7 +4,7 @@ t.column :author_id, :integer t.column :publication_id, :integer t.column :name_on_paper, :string - t.column :order, :integer + t.column :auth_order, :integer t.column :institution, :string t.column :email, :string end