Revision 458:f2288bb384bb vendor/plugins/redmine_bibliography

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
vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb
1
<% form_for @publication do |f| -%>
1
<% form_for @publication, :url => { :project_id  => @project_id, :action => :create } do |f| -%>
2

  
2 3
  <%= f.error_messages %>
3 4
  
4 5
  <p><%= f.label :title, l(:title) %>  <%= f.text_field :title %></p>
......
14 15
    <%= render :partial => 'bibtex_fields', :locals => { :f => builder}  %>
15 16
  <%- end -%>
16 17

  
18

  
17 19
  <%= f.submit %>
18 20

  
19 21
<% end -%>
vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb
1
<div class="contextual">
2
	<% if User.current.allowed_to?(:add_publication, @project) %>
3
		<%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %>
4
	<% end %>
1
<div class="contextual">		
2
		<%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
5 3
</div>
6 4

  
7 5
<div class="splitcontentleft">
vendor/plugins/redmine_bibliography/init.rb
26 26

  
27 27
  project_module :redmine_bibliography do
28 28
    permission :publications, { :publications => :index }, :public => true
29
    permission :edit_redmine_bibliography, {:redmine_bibliography => [:index, :edit]}
30
    permission :add_publication, {:redmine_bibliography => :index}, :public => :true
29
    permission :edit_redmine_bibliography, {:redmine_bibliography => [:edit, :update]}, :public => true
30
    permission :add_publication, {:redmine_bibliography => [:new, :create]}, :public => true
31 31
  end
32 32

  
33 33
  # extending the Project Menu

Also available in: Unified diff