Revision 409:50474139cad4 vendor/plugins/redmine_bibliography/app

View differences:

vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
8 8

  
9 9
    # the step we're at in the form
10 10
    @publication.current_step = session[:publication_step]
11

  
12
    @new_publications = []
13
    session[:publications] ||= {}
14
      
11 15
  end
12 16

  
13 17
  def create
14 18
    @publication = Publication.new(params[:publication])
15 19
    @publication.current_step = session[:publication_step]
16

  
20
    
17 21
    # contents of the paste text area
18 22
    bibtex_entry = params[:bibtex_entry]
19 23

  
20 24
    # method for creating "pasted" bibtex entries
21
    if bibtex_entry
22
      parse_bibtex_list bibtex_entry
25
    if bibtex_entry      
26
      parse_bibtex_list bibtex_entry    
23 27
    end
24 28

  
25 29
    # form's flow control
......
31 35

  
32 36
    session[:publication_step] = @publication.current_step
33 37

  
34
    render "new"
38
    if @publication.new_record?
39
      render "new"
40
    else
41
      session[:publication_step] = session[:publication_params] = nil
42
      flash[:notice] = "New publication saved!"
43
      redirect_to @publication
44
    end
35 45
  end
36 46

  
37

  
38 47
  def index
39 48
    @publications = Publication.find(:all)
40 49
  end
......
76 85
    end
77 86
  end 
78 87

  
79
  def create_bibtex_entry(d)    
88
  def create_bibtex_entry(d)        
80 89
    @publication = Publication.new
81 90
    @bentry = BibtexEntry.new        
82 91
    authors = []
83 92
    institution = ""
84 93
    email = ""
85
      
94

  
86 95
    d.fields.keys.map do |field|
87 96
      case field.to_s
88 97
      when "author"
......
100 109

  
101 110
    @publication.bibtex_entry = @bentry
102 111
    @publication.save
103
    
112

  
113
    @created_publications << @publication.id
114

  
104 115
    # need to save all authors
105 116
    #   and establish the author-publication association 
106 117
    #   via the authorships table 
......
117 128
      :institution => institution,
118 129
      :email => email,
119 130
      :order => idx)
120
      
131

  
121 132
    end
122 133
  end
123
  
124
  
134

  
125 135
  # parses the bibtex file
126 136
  def parse_bibtex_file
127 137

  
128 138
  end
129 139

  
130
  
140

  
141
  def review_new_entries
142

  
143
  end
144

  
145

  
131 146
end
vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb
1 1
<h3>New Bibtex</h3>
2 2

  
3
<h4>Paste your bibtex entries here</h4>
3
<h4>Paste your Bibtex entries here</h4>
4 4
<p>
5 5
  <%=label_tag :bibtex_entry %>
6 6
  <%=text_area_tag :bibtex_entry%>  
vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
5 5

  
6 6
  <%= render :partial  => "#{@publication.current_step}_bibtex_step", :locals => { :f => f }  %>
7 7

  
8
  <%= f.submit "Submit" %>
8
  <p><%= f.submit "Submit" %></p>
9
  <p><%= f.submit "Back", :name => "back_button" unless @publication.first_step? %></p>
9 10
  
10 11
<% end %>
11 12

  

Also available in: Unified diff