Mercurial > hg > soundsoftware-site
changeset 458:f2288bb384bb feature_36
Creates and lists publications from the project tab.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 15 Jun 2011 17:40:18 +0100 |
parents | 8aa775cb7c0a |
children | 0f9097245756 |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb vendor/plugins/redmine_bibliography/init.rb |
diffstat | 4 files changed, 19 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Jun 14 17:51:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jun 15 17:40:18 2011 +0100 @@ -3,7 +3,7 @@ class PublicationsController < ApplicationController unloadable - before_filter :find_project, :authorize, :only => [:index, :new] + before_filter :find_project_by_project_id def new @publication = Publication.new @@ -14,6 +14,8 @@ # and at least one author @publication.authors.build + @project_id = params[:project_id] + # the step we're at in the form @publication.current_step = session[:publication_step] @@ -23,7 +25,13 @@ def create @publication = Publication.new(params[:publication]) + @project = Project.find(params[:project_id]) + logger.error { "FIGUEIRA" } + Rails.logger.debug { @project } + + @publication.projects << @project + if @publication.save flash[:notice] = "Successfully created publication." redirect_to @publication @@ -33,7 +41,8 @@ end def index - @publications = Publication.find(:all) + @project = Project.find(params[:project_id]) + @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id] end def new_from_bibfile @@ -157,7 +166,6 @@ :institution => institution, :email => email, :order => idx) - end end @@ -179,10 +187,9 @@ private - def find_project + def find_projectx # @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/_edit.html.erb Tue Jun 14 17:51:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Wed Jun 15 17:40:18 2011 +0100 @@ -1,4 +1,5 @@ -<% form_for @publication do |f| -%> +<% form_for @publication, :url => { :project_id => @project_id, :action => :create } do |f| -%> + <%= f.error_messages %> <p><%= f.label :title, l(:title) %> <%= f.text_field :title %></p> @@ -14,6 +15,7 @@ <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> <%- end -%> + <%= f.submit %> <% end -%>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Tue Jun 14 17:51:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Wed Jun 15 17:40:18 2011 +0100 @@ -1,7 +1,5 @@ -<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 class="contextual"> + <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> </div> <div class="splitcontentleft">
--- a/vendor/plugins/redmine_bibliography/init.rb Tue Jun 14 17:51:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/init.rb Wed Jun 15 17:40:18 2011 +0100 @@ -26,8 +26,8 @@ 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 + permission :edit_redmine_bibliography, {:redmine_bibliography => [:edit, :update]}, :public => true + permission :add_publication, {:redmine_bibliography => [:new, :create]}, :public => true end # extending the Project Menu