Mercurial > hg > soundsoftware-site
changeset 404:216a61338322 feature_36
comments and refactoring
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 13 Apr 2011 14:29:12 +0100 |
parents | b15397a5341c |
children | 8a105a53b8f4 |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb |
diffstat | 1 files changed, 42 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Apr 12 16:35:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Apr 13 14:29:12 2011 +0100 @@ -13,57 +13,60 @@ end def parse_bibtex_text - bibtex_entry = params[:bibtex_entry] + bib = BibTeX.parse bibtex_entry - logger.error bibtex_entry + # parses the bibtex entries + bib.data.map do |d| + result = '' + if d.class == BibTeX::Entry + @bentry = BibtexEntry.new + # d.replace!(bib.strings) - if bibtex_entry - bib = BibTeX.parse bibtex_entry + d.fields.keys.map do |k| + if k == "title" + @publication.title = d[k] + else + @bentry[k] = d[k] + end + end + end + end + + @publication.bibtex_entry = @bentry + + if @publication.save + logger.error "SAVED" + else + logger.error "NOT SAVED" + end - # parses the bibtex entries - bib.data.map do |d| - result = '' - if d.class == BibTeX::Entry - @bentry = BibtexEntry.new - # d.replace!(bib.strings) + logger.error @publication.bibtex_entry + end - d.fields.keys.map do |k| - if k == "title" - @publication.title = d[k] - else - @bentry[k] = d[k] - end - end - end - end - - @publication.bibtex_entry = @bentry - - if @publication.save - logger.error "SAVED" - else - logger.error "NOT SAVED" - end - - logger.error @publication.bibtex_entry - - end + def new + # we always try to create at least one publication + @publication = Publication.new + + # the step we're at in the form + @publication.current_step = session[:publication_step] end - def new - @publication = Publication.new - @publication.current_step = session[:publication_step] - - end - - def create + def create @publication = Publication.new(params[:publication]) @publication.current_step = session[:publication_step] - parse_bibtex_text + # contents of the paste text area + bibtex_entry = params[:bibtex_entry] + # debug message + logger.error bibtex_entry + # method for creating "pasted" bibtex entries + if bibtex_entry + parse_bibtex_text + end + # form's flow control if params[:back_button] @publication.previous_step else