diff vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb @ 702:3eb64cb3c7ac feature_36

Link authorships from publications detail page as well as publications list. Also minor text update
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Mon, 19 Sep 2011 17:00:35 +0100
parents aed18b463206
children
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb	Mon Sep 19 16:44:43 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb	Mon Sep 19 17:00:35 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