changeset 1109:dfa5d63d40b4 bibplugin_bibtex

No longer saving the temporary model - filling out the publication/bibtex fields instead.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 06 Dec 2012 18:09:40 +0000
parents afac109ac063
children e48a7a36491b
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs
diffstat 2 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Dec 06 16:37:47 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Dec 06 18:09:40 2012 +0000
@@ -25,21 +25,28 @@
 
   # the argument is a ruby-bibtex parsed entry
   def create_bibtex_entry(bibtex)
+    logger.error { "BIBTEX.type -->#{bibtex.type}" }
+    @publication.bibtex_entry.entry_type = BibtexEntryType.find_by_name(bibtex.type.to_s).id
+
+    logger.error { ">>>>>TYPE #{bibtex.type}->#{@publication.bibtex_entry.entry_type}<<<<" }
 
     bibtex.fields.keys.map do |field|
       case field.to_s
       when "title"
-        @publication.title = bibtex[field]
+        @publication.title = bibtex[:title].to_s
       when "author"
         bibtex.authors.each do |auth|
           logger.error { "AUTHOR #{auth}" }
         end
       else
-        @publication.bibtex_entry[field] = bibtex[field]
+        @publication.bibtex_entry[field.to_sym] = bibtex[field].to_s
       end
     end
   end
 
+
+
+
   def parse_bibtex
     find_project_by_project_id
     @bibtex_parse_success = true
@@ -68,7 +75,7 @@
 
           # creates the entry
           create_bibtex_entry(bib[0])
-          logger.error { "Bibtex Entry #{@bibtex_entry}" }
+          logger.error { "Bibtex Entry #{@bibtex_entry} of type #{bib[0].type}" }
 
           @ieee_prev = CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html
           bibtex_parsed_authors = bib[0].authors
@@ -81,13 +88,6 @@
             logger.error { "Added Authorship: #{auth}" }
           end
 
-          # we can now temporarily save this publication
-          # note that the publication still needs reviewing
-          # we are skipping the validation we only have authorships
-          # associated with the publication at this stage
-
-          # in Rails 3 this should be changed to :validate => false
-          @publication.save(false)
         end
 
         # todo: response for HTML
@@ -95,11 +95,14 @@
     end
   end
 
+
   def create_from_bibtex
     find_project_by_project_id
 
+    @publication = Publication.new(params[:publication])
     debugger
 
+
   end
 
   def create
--- a/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs	Thu Dec 06 16:37:47 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs	Thu Dec 06 18:09:40 2012 +0000
@@ -6,10 +6,14 @@
     page.insert_html :bottom, :suggest_bibtex_authors, :partial => "suggest_author", :locals => {:suggestions => auth, :index => idx}
   end
 
-  page["bibtex_pub_id"].value = @publication.id
+  page[:publication_title].value = @publication.title
+
+  @publication.bibtex_entry.attributes.each do |k,v|
+    page["publication_bibtex_entry_attributes_#{k}"].value = v.to_s unless v.nil?
+  end
 
 else
   page.insert_html :top, :content, '<div class="flash error">Error parsing BibTeX.</div>'
 end
 
-flash.discard
\ No newline at end of file
+flash.discard