comparison vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 608:c7559c3a8d03 feature_36

Fixed a bug when a validation error occurs: keeps the project_id so that the publication is still saved in the same circumstances.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 18 Aug 2011 22:27:19 +0100
parents bdaabf6ee591
children 3221b2ab7804
comparison
equal deleted inserted replaced
607:bdaabf6ee591 608:c7559c3a8d03
14 14
15 # we'll always want a new publication to have its bibtex entry 15 # we'll always want a new publication to have its bibtex entry
16 @publication.build_bibtex_entry 16 @publication.build_bibtex_entry
17 17
18 # and at least one author 18 # and at least one author
19 # @publication.authorships.build.build_author 19 # @publication.authorships.build.build_author
20
21 @project_id = params[:project_id]
22 @current_user = User.current
23
24 @author_options = Authorship.like_unique(User.name).find(:all, :limit => 100) 20 @author_options = Authorship.like_unique(User.name).find(:all, :limit => 100)
25 end 21 end
26 22
27 def create 23 def create
28 find_project_by_project_id 24 @project_id = params[:project_id]
29
30 @author_options = Authorship.like_unique(User.name).find(:all, :limit => 100) 25 @author_options = Authorship.like_unique(User.name).find(:all, :limit => 100)
31 26
32
33 @publication = Publication.new(params[:publication]) 27 @publication = Publication.new(params[:publication])
34 28
35 # @project = Project.find(params[:project_id]) 29 # @project = Project.find(params[:project_id])
36 @publication.projects << @project unless @project.nil? 30 @publication.projects << @project unless @project.nil?
37 31
38 if @publication.save 32 if @publication.save
39 flash[:notice] = "Successfully created publication." 33 flash[:notice] = "Successfully created publication."
40 redirect_to :action => :show, :id => @publication, :project_id => @project.id 34 redirect_to :action => :show, :id => @publication, :project_id => @project.id
41 else 35 else
42 render :action => 'new' 36 render :action => 'new', :project_id => @project_id
43 end 37 end
44 end 38 end
45 39
46 def index 40 def index
47 if !params[:project_id].nil? 41 if !params[:project_id].nil?