changeset 409:50474139cad4 feature_36

DEV commit; new logic.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 15 Apr 2011 19:02:51 +0100
parents cd3158bf28b5
children b601a9e472f3
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
diffstat 3 files changed, 30 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Fri Apr 15 16:58:37 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Fri Apr 15 19:02:51 2011 +0100
@@ -8,18 +8,22 @@
 
     # the step we're at in the form
     @publication.current_step = session[:publication_step]
+
+    @new_publications = []
+    session[:publications] ||= {}
+      
   end
 
   def create
     @publication = Publication.new(params[:publication])
     @publication.current_step = session[:publication_step]
-
+    
     # contents of the paste text area
     bibtex_entry = params[:bibtex_entry]
 
     # method for creating "pasted" bibtex entries
-    if bibtex_entry
-      parse_bibtex_list bibtex_entry
+    if bibtex_entry      
+      parse_bibtex_list bibtex_entry    
     end
 
     # form's flow control
@@ -31,10 +35,15 @@
 
     session[:publication_step] = @publication.current_step
 
-    render "new"
+    if @publication.new_record?
+      render "new"
+    else
+      session[:publication_step] = session[:publication_params] = nil
+      flash[:notice] = "New publication saved!"
+      redirect_to @publication
+    end
   end
 
-
   def index
     @publications = Publication.find(:all)
   end
@@ -76,13 +85,13 @@
     end
   end 
 
-  def create_bibtex_entry(d)    
+  def create_bibtex_entry(d)        
     @publication = Publication.new
     @bentry = BibtexEntry.new        
     authors = []
     institution = ""
     email = ""
-      
+
     d.fields.keys.map do |field|
       case field.to_s
       when "author"
@@ -100,7 +109,9 @@
 
     @publication.bibtex_entry = @bentry
     @publication.save
-    
+
+    @created_publications << @publication.id
+
     # need to save all authors
     #   and establish the author-publication association 
     #   via the authorships table 
@@ -117,15 +128,19 @@
       :institution => institution,
       :email => email,
       :order => idx)
-      
+
     end
   end
-  
-  
+
   # parses the bibtex file
   def parse_bibtex_file
 
   end
 
-  
+
+  def review_new_entries
+
+  end
+
+
 end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb	Fri Apr 15 16:58:37 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb	Fri Apr 15 19:02:51 2011 +0100
@@ -1,6 +1,6 @@
 <h3>New Bibtex</h3>
 
-<h4>Paste your bibtex entries here</h4>
+<h4>Paste your Bibtex entries here</h4>
 <p>
   <%=label_tag :bibtex_entry %>
   <%=text_area_tag :bibtex_entry%>  
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Fri Apr 15 16:58:37 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Fri Apr 15 19:02:51 2011 +0100
@@ -5,7 +5,8 @@
 
   <%= render :partial  => "#{@publication.current_step}_bibtex_step", :locals => { :f => f }  %>
 
-  <%= f.submit "Submit" %>
+  <p><%= f.submit "Submit" %></p>
+  <p><%= f.submit "Back", :name => "back_button" unless @publication.first_step? %></p>
   
 <% end %>