# HG changeset patch # User luisf # Date 1302525077 -3600 # Node ID 9595ab4cac6b3378296889a3d5cf6a2fcd1c9d5a # Parent b97577523b0c714455eb6c3e45e3b25a8c336341 DEV Commit: more logic to the publication controller; bibtexentry model, fixtures, test diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Apr 11 12:34:18 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Apr 11 13:31:17 2011 +0100 @@ -5,11 +5,11 @@ # parse string with bibtex authors # return an ordered array def parse_authors - + end def parse_bibtex_file - + end def parse_bibtex_text @@ -17,24 +17,31 @@ if bibtex_entry bib = BibTeX.parse bibtex_entry - + # parses the bibtex entries bib.data.map do |d| result = '' if d.class == BibTeX::Entry + @bentry = BibtexEntry.new # d.replace!(bib.strings) - - result = [author, '. ', d.title].join - end + + d.fields.keys.map do |k| + @bentry[k] = d[k] + end + end end - end - end + @publication.bibtex_entry = @bentry + + logger.error @publication.bibtex_entry + + end + end def new @publication = Publication.new @publication.current_step = session[:publication_step] - + end def create @@ -43,14 +50,20 @@ parse_bibtex_text + if @publication.save + logger.error "SAVED" + else + logger.error "NOT SAVED" + end + if params[:back_button] @publication.previous_step else @publication.next_step end - + session[:publication_step] = @publication.current_step - + render "new" end @@ -75,5 +88,4 @@ @authors = @publication.authors end - end diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/app/models/authorship.rb --- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Mon Apr 11 12:34:18 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Mon Apr 11 13:31:17 2011 +0100 @@ -1,4 +1,5 @@ class Authorship < ActiveRecord::Base belongs_to :author belongs_to :publication + end diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Mon Apr 11 13:31:17 2011 +0100 @@ -0,0 +1,4 @@ +class BibtexEntry < ActiveRecord::Base + belongs_to :publication + +end diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Mon Apr 11 12:34:18 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Mon Apr 11 13:31:17 2011 +0100 @@ -3,6 +3,7 @@ class Publication < ActiveRecord::Base has_many :authorships has_many :authors, :through => :authorships + has_one :bibtex_entry validates_presence_of :title diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml Mon Apr 11 13:31:17 2011 +0100 @@ -0,0 +1,53 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 + entry_type: + address: + annote: + booktitle: + chapter: + crossref: + edition: + editor: + eprint: + howpublished: + journal: + key: + month: + note: + number: + organization: + pages: + publisher: + school: + series: + type: + url: + volume: + year: 1 +two: + id: 2 + entry_type: + address: + annote: + booktitle: + chapter: + crossref: + edition: + editor: + eprint: + howpublished: + journal: + key: + month: + note: + number: + organization: + pages: + publisher: + school: + series: + type: + url: + volume: + year: 1 diff -r b97577523b0c -r 9595ab4cac6b vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb Mon Apr 11 13:31:17 2011 +0100 @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class BibtexEntryTest < ActiveSupport::TestCase + fixtures :bibtex_entries + + # Replace this with your real tests. + def test_truth + assert true + end +end