Revision 458:f2288bb384bb vendor/plugins/redmine_bibliography/app/controllers

View differences:

vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
3 3
class PublicationsController < ApplicationController
4 4
  unloadable
5 5
  
6
  before_filter :find_project, :authorize, :only => [:index, :new]
6
  before_filter :find_project_by_project_id
7 7
  
8 8
  def new
9 9
    @publication = Publication.new      
......
14 14
    # and at least one author
15 15
    @publication.authors.build
16 16
    
17
    @project_id = params[:project_id]
18
    
17 19
    # the step we're at in the form
18 20
    @publication.current_step = session[:publication_step]
19 21

  
......
23 25

  
24 26
  def create
25 27
    @publication = Publication.new(params[:publication])
28
    @project = Project.find(params[:project_id])
26 29

  
30
    logger.error { "FIGUEIRA" }
31
    Rails.logger.debug { @project }
32

  
33
    @publication.projects << @project
34
    
27 35
    if @publication.save 
28 36
      flash[:notice] = "Successfully created publication."
29 37
      redirect_to @publication
......
33 41
  end
34 42

  
35 43
  def index
36
    @publications = Publication.find(:all)
44
    @project = Project.find(params[:project_id])
45
    @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id]
37 46
  end
38 47

  
39 48
  def new_from_bibfile
......
157 166
        :institution => institution,
158 167
        :email => email,
159 168
        :order => idx)
160

  
161 169
    end
162 170
  end
163 171

  
......
179 187
  
180 188
  private
181 189
   
182
  def find_project
190
  def find_projectx
183 191
   # @project variable must be set before calling the authorize filter
184 192
   @project = Project.find(params[:project_id])
185 193
  end
186 194

  
187

  
188 195
end

Also available in: Unified diff