changeset 457:8aa775cb7c0a feature_36

changes to views and publicatioins controller
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 14 Jun 2011 17:51:26 +0100
parents 773fe1222605
children f2288bb384bb
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb vendor/plugins/redmine_bibliography/config/locales/en.yml vendor/plugins/redmine_bibliography/init.rb
diffstat 4 files changed, 47 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Tue Jun 14 16:47:19 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Tue Jun 14 17:51:26 2011 +0100
@@ -1,9 +1,10 @@
 # vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
 
 class PublicationsController < ApplicationController
-  # TODO: should be removed on production version?
   unloadable
-
+  
+  before_filter :find_project, :authorize, :only => [:index, :new]
+  
   def new
     @publication = Publication.new      
     
@@ -32,7 +33,6 @@
   end
 
   def index
-    @project = Project.find(params[:project_id])
     @publications = Publication.find(:all)
   end
 
@@ -175,6 +175,14 @@
   def review_new_entries
 
   end
+  
+  
+  private
+   
+  def find_project
+   # @project variable must be set before calling the authorize filter
+   @project = Project.find(params[:project_id])
+  end
 
 
 end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb	Tue Jun 14 16:47:19 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb	Tue Jun 14 17:51:26 2011 +0100
@@ -1,16 +1,35 @@
-<h2>Publications#index</h2>
+<div class="contextual">
+	<% if User.current.allowed_to?(:add_publication, @project) %>
+		<%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %>
+	<% end %>
+</div>
 
+<div class="splitcontentleft">
+  <h3>Publications#index</h3>
 
-<table>
-  <tr>
-    <th>Number</th>
-    <th>Title</th> 
-  </tr>
 
-<% @publications.each do |publication| %>
-	<tr>
-	  <td><%= publication.id %></td>
-	  <td><%= publication.title %></td>
-	 	</tr>
-	
-<% end %>
\ No newline at end of file
+  <table>
+    <tr>
+      <th>Number</th>
+      <th>Title</th> 
+    </tr>
+
+    <% @publications.each do |publication| %>
+	    <tr>
+	      <td><%= publication.id %></td>
+	      <td><%= publication.title %></td>
+	 	  </tr>
+    <% end %>    
+  </table>
+
+</div>
+
+<div class="splitcontentright">
+  placeholder div
+</div>
+
+
+<% content_for :sidebar do %>
+  Sidebar
+<% end %>
+  
\ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml	Tue Jun 14 16:47:19 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml	Tue Jun 14 17:51:26 2011 +0100
@@ -6,6 +6,9 @@
   name: "Name"
 
   remove: "Remove"
+  
+  label_publication_new: "Add Publication"
+  
       
   # bibtex_entries strings
   id: "id" 
--- a/vendor/plugins/redmine_bibliography/init.rb	Tue Jun 14 16:47:19 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/init.rb	Tue Jun 14 17:51:26 2011 +0100
@@ -27,6 +27,7 @@
   project_module :redmine_bibliography do
     permission :publications, { :publications => :index }, :public => true
     permission :edit_redmine_bibliography, {:redmine_bibliography => [:index, :edit]}
+    permission :add_publication, {:redmine_bibliography => :index}, :public => :true
   end
 
   # extending the Project Menu