Mercurial > hg > soundsoftware-site
diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 538:e25248ba597c feature_36
Fixed project_id parameter bug related to Issue #217.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 27 Jul 2011 16:49:38 +0100 |
parents | dd9d9c0ff0f9 |
children | d4bf55b01092 |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Jul 26 18:25:14 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jul 27 16:49:38 2011 +0100 @@ -3,7 +3,7 @@ class PublicationsController < ApplicationController unloadable - # before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author] + # before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author] def new @publication = Publication.new @@ -41,8 +41,13 @@ end def index - @project = Project.find(params[:project_id]) - @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id] + if !params[:project_id].nil? + find_project_by_project_id + @project = Project.find(params[:project_id]) + @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id] + else + @publications = Publication.find :all + end end def new_from_bibfile @@ -73,30 +78,33 @@ def update @publication = Publication.find(params[:id]) + if @publication.update_attributes(params[:publication]) flash[:notice] = "Successfully updated Publication." - redirect_to @publication + + if !params[:project_id].nil? + redirect_to :action => :show, :id => @publication, :project_id => params[:project_id] + else + redirect_to :action => :show, :id => @publication + end else render :action => 'edit' end end def show + logger.error { "PARAMS PROJECT_ID #{params[:project_id]} <---" } + find_project_by_project_id unless params[:project_id].nil? @publication = Publication.find(params[:id]) if @publication.nil? @publications = Publication.all - render "index", :alert => 'Your Publications was not found!' + render "index", :alert => 'The publication was not found!' else @authors = @publication.authors @bibtext_entry = @publication.bibtex_entry - - respond_to do |format| - format.html - format.xml {render :xml => @publication} - end end end @@ -230,18 +238,6 @@ end + private - - private - - # TODO: luisf. - only here for debugging purposes - # Find project of id params[:project_id] - def find_project_by_project_id - - logger.error { "FIND PROJECT BY PROJECT ID" } - - @project = Project.find(params[:project_id]) - rescue ActiveRecord::RecordNotFound - render_404 - end end