# HG changeset patch # User luisf # Date 1314202691 -3600 # Node ID e2663e0bd5a6d4a0192cfc36fcf80ebf644a38e1 # Parent a434a588f16c15470314bcec7068fc0f4dee3703 Continued work on permissions (Feature #241 and Feature #242). diff -r a434a588f16c -r e2663e0bd5a6 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- 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]) diff -r a434a588f16c -r e2663e0bd5a6 vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml --- 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 %> diff -r a434a588f16c -r e2663e0bd5a6 vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- 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 -%>
- <%= 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 %> - <% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> <% content_for :sidebar do %> diff -r a434a588f16c -r e2663e0bd5a6 vendor/plugins/redmine_bibliography/config/locales/en.yml --- 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" diff -r a434a588f16c -r e2663e0bd5a6 vendor/plugins/redmine_bibliography/init.rb --- 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