changeset 691:f8d7e85ccd4e feature_36

Feature #293: lists the projects associated with a publication.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 16 Sep 2011 17:06:58 +0100
parents 1f488f375d64
children dd366a17ab34
files vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb vendor/plugins/redmine_bibliography/config/locales/en.yml
diffstat 4 files changed, 39 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Fri Sep 16 15:49:29 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Fri Sep 16 17:06:58 2011 +0100
@@ -72,29 +72,28 @@
     str = object_name.split("\[").last().gsub("\]","")
     str.to_sym
   end
-  
-  def render_projects_list(publication)
-    logger.error { "PROJECT NAME #{@project.name unless @project.nil?}" }
     
-    s = ""
-
-    publication.projects.each do |proj|
+  def render_projects_list(publication, show_delete_icon)    
+    s= ""
+    
+    publication.projects.visible.each do |proj|
       s << link_to_project(proj, {}, :class => 'publication_project')
-      
-      if User.current.allowed_to?(:edit_publication, @project)
-        if @project == proj
-          confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?'
-        else
-          confirm_msg = false
-        end 
-            
-        s << link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del') 
+    
+      if show_delete_icon  
+        if User.current.allowed_to?(:edit_publication, @project)
+          if @project == proj
+            confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?'
+          else
+            confirm_msg = false
+          end 
+          
+          s << link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del') 
+        end
       end
       
-      s << "<br />"
-      
-    end
-    
+      s << "<br />"      
+    end    
+
     s  
   end
   
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb	Fri Sep 16 15:49:29 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb	Fri Sep 16 17:06:58 2011 +0100
@@ -1,1 +1,1 @@
-<%= render_projects_list(@publication) %>
+<%= render_projects_list(@publication, true) %>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb	Fri Sep 16 15:49:29 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb	Fri Sep 16 17:06:58 2011 +0100
@@ -5,9 +5,9 @@
 </div>
 
   <% if @project %>
-  <h3><%= l(:label_all_publications_for_project, :project => @project.name) %></h3>
+    <h3><%= l(:label_all_publications_for_project, :project => @project.name) %></h3>
   <% else %>
-  <h3><%= l(:label_all_publications) %></h3>
+    <h3><%= l(:label_all_publications) %></h3>
   <% end %>
 
   <div class="autoscroll">
@@ -15,24 +15,27 @@
     <thead><tr>
       <th><%= l(:title) %></th> 
       <th><%= l(:authors) %></th> 
-      <th><%= l(:year) %></th> 
+      <th><%= l(:year) %></th>
+      <th><%= l(:associated_projects) %></th>
     </tr></thead>
 
-    <% @publications.each do |publication| %>
-    <tr class="<%= cycle('odd', 'even') %>">
-      <td class="firstcol title" align="top"><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td>
-      <td class="authors" align="top">
-	      <% publication.authorships.each do |authorship| %>
+    <% @publications.each do |publication| %>        
+      <tr class="<%= cycle('odd', 'even') %>">
+        <td class="firstcol title" align="top"><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td>
+        <td class="authors" align="top">
+	        <% publication.authorships.each do |authorship| %>
 	          <%# if authorship.author.user.nil? || !authorship.author.user.active? %>
-	            <%= h authorship.name_on_paper %>
+	          <%= h authorship.name_on_paper %>
 	          <%# else %>
-              <%#= link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user) %>
-	          <%# end %>
-	          
-	<em><%= authorship.institution %></em><br/>
-	<% end %>
-      <td class="year"><%= publication.bibtex_entry.year %></td>
-    </tr>
+            <%#= link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user) %>
+	          <%# end %>        
+	          <em><%= authorship.institution %></em><br/>
+	        <% end %>
+        <td class="year"><%= publication.bibtex_entry.year %></td>
+        <td class="projects">
+          <%= render_projects_list(publication, false) %>
+        </td>
+      </tr>
     <% end %>    
   </table>
   </div>
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml	Fri Sep 16 15:49:29 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml	Fri Sep 16 17:06:58 2011 +0100
@@ -7,6 +7,7 @@
   author: "Author"
   name: "Name"
   year: "Year"
+  associated_projects: "Associated Projects"
   publications_box: "My Publications"
   label_my_publications_box: "My Publications"
   view_all_publications: "View All Project's Publications"