diff vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb @ 720:5eb7efd59ed7 cannam

Merge
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Mon, 17 Oct 2011 16:58:48 +0100
parents 3eb64cb3c7ac
children
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb	Mon Oct 17 16:58:32 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb	Mon Oct 17 16:58:48 2011 +0100
@@ -1,2 +1,21 @@
+# -*- coding: undecided -*-
 module AuthorshipsHelper
+
+  # Generates a link to either author or user, depending on which is
+  # available
+  def link_to_authorship(authorship)
+    s = ''
+    if authorship.author.nil?
+      # legacy reasons…
+      s << h(authorship.name_on_paper)
+    else
+      if authorship.author.user.nil?      
+        s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author)
+      else
+        s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user)
+      end
+    end
+    s
+  end
+
 end