changeset 626:e2663e0bd5a6 feature_36

Continued work on permissions (Feature #241 and Feature #242).
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 24 Aug 2011 17:18:11 +0100
parents a434a588f16c
children 91143e21be2c
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb vendor/plugins/redmine_bibliography/config/locales/en.yml vendor/plugins/redmine_bibliography/init.rb
diffstat 5 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Aug 24 15:44:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Aug 24 17:18:11 2011 +0100
@@ -5,12 +5,11 @@
   unloadable
   
   model_object Publication
-  before_filter :find_model_object, :except => [:new, :create, :index, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]
-  
+  before_filter :find_model_object, :except => [:new, :create, :index, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]  
+  before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author]  
   before_filter :find_project_by_project_id, :authorize, :only => :edit
-
-
-  # before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author]
+    
+    
     
   def new
     find_project_by_project_id
@@ -81,12 +80,18 @@
     
     @options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
     @publication = Publication.find(params[:id])
-    @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type  
+    @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
+
+    # todo: should be removed? 
+    @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]  
   end
 
   def update    
     @publication = Publication.find(params[:id])        
 
+    # todo: should be removed? 
+    @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
+
     logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" }
 
     if @publication.update_attributes(params[:publication])
--- a/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml	Wed Aug 24 15:44:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml	Wed Aug 24 17:18:11 2011 +0100
@@ -4,7 +4,9 @@
 	<% end %>
 	
 	<% if @project.module_enabled? :redmine_bibliography %>
-		<%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>		
+	  <% if User.current.allowed_to?(:add_publication, @project) %>	
+		  <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>		
+	  <% end %>
 	<% end %>
 </div>
 
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Aug 24 15:44:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Aug 24 17:18:11 2011 +0100
@@ -23,13 +23,14 @@
 <%- end -%>
 
 <br>
-  <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> |
-  <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project },
+  <% if User.current.allowed_to?(:add_publication, @project) %>	
+    <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> |
+    <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project },
                                                      :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> |
-  <%= link_to "View All", publications_path %>
+  <% end %>
+  <%= link_to l(:view_all_publications), publications_path %>
 </div>
 
-
 <% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
 
 <% content_for :sidebar do %>
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml	Wed Aug 24 15:44:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml	Wed Aug 24 17:18:11 2011 +0100
@@ -7,6 +7,7 @@
   year: "Year"
   publications_box: "My Publications"
   label_my_publications_box: "My Publications"
+  view_all_publications: "View All Project's Publications"
   
   identify_author_question: Is the right person selected above?
   identify_author_yes: "Yes"
--- a/vendor/plugins/redmine_bibliography/init.rb	Wed Aug 24 15:44:55 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/init.rb	Wed Aug 24 17:18:11 2011 +0100
@@ -31,9 +31,9 @@
   settings :default => { 'menu' => 'Bibliography' }, :partial => 'settings/bibliography'
 
   project_module :redmine_bibliography do
-    permission :publications, { :publications => :index }
-    permission :edit_publication, {:redmine_bibliography => [:edit, :update]}
-    permission :add_publication, {:redmine_bibliography => [:new, :create]}
+    permission :publications, { :publication => :index }, :public => true
+    permission :edit_publication, {:publication => [:edit, :update]}
+    permission :add_publication, {:publication => [:new, :create]}
   end
 
   # extending the Project Menu