# HG changeset patch
# User luisf
# Date 1307536180 -3600
# Node ID 995d4c99843d3c074a7dc92d345fd3217d7d36be
# Parent 77f88379115ac9fb9a52b1d011759e0b66183662
New form saving models correctly. BUG: duplicate authors in authorships table
diff -r 77f88379115a -r 995d4c99843d vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jun 08 11:35:04 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jun 08 13:29:40 2011 +0100
@@ -10,6 +10,9 @@
# we'll always want a new publication to have its bibtex entry
@publication.build_bibtex_entry
+ # and at least one author
+ @publication.authors.build
+
# the step we're at in the form
@publication.current_step = session[:publication_step]
diff -r 77f88379115a -r 995d4c99843d vendor/plugins/redmine_bibliography/app/models/publication.rb
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Jun 08 11:35:04 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Jun 08 13:29:40 2011 +0100
@@ -5,15 +5,14 @@
has_many :authorships
has_many :authors, :through => :authorships
+
has_one :bibtex_entry, :dependent => :destroy
validates_presence_of :title
accepts_nested_attributes_for :authorships
- accepts_nested_attributes_for :authors, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
-# accepts_nested_attributes_for :bibtex_entry, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
-
-
+ accepts_nested_attributes_for :authors, :allow_destroy => true
+ accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true
attr_writer :current_step
diff -r 77f88379115a -r 995d4c99843d vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Wed Jun 08 11:35:04 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Wed Jun 08 13:29:40 2011 +0100
@@ -12,6 +12,9 @@
<%- end -%>
+
+ Other Details
+
<% f.fields_for :bibtex_entry do |bib| -%>
<%= bib.label :year, l(:year) %> <%= bib.text_field :year %>
diff -r 77f88379115a -r 995d4c99843d vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Wed Jun 08 11:35:04 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Wed Jun 08 13:29:40 2011 +0100
@@ -3,9 +3,9 @@
<%= h @publication.title %>
Authors
-<% @publication.authors.each do |author| %>
-<%= h author.name %>
-<% end %>
+ <% for author in @publication.authors %>
+ <%= h author.name %>
+ <% end %>
<%- if @publication.bibtex_entry != nil -%>