changeset 567:5404f7dfb4b3 feature_36

Move set_initial_author_order to before_save to avoid duplicate author creation; Remove unwanted has-one relationship between user and publication
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 09 Aug 2011 14:30:22 +0100
parents b18f19710242
children 049a1bcf38f1 f1ef29202956
files vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb
diffstat 2 files changed, 2 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Tue Aug 09 14:29:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Tue Aug 09 14:30:22 2011 +0100
@@ -16,7 +16,7 @@
   
   has_and_belongs_to_many :projects, :uniq => true
   
-  after_save :set_initial_author_order
+  before_save :set_initial_author_order
   
   def set_initial_author_order
     authorships = self.authorships
@@ -26,7 +26,6 @@
     authorships.each_with_index do |authorship, index|
       if authorship.auth_order.nil?
          authorship.auth_order = index
-         authorship.update
       end
     end    
   end
--- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb	Tue Aug 09 14:29:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb	Tue Aug 09 14:30:22 2011 +0100
@@ -6,10 +6,6 @@
       base.send(:include, InstanceMethods) 
       extend ClassMethods     
           
-      base.class_eval do
-        has_one :publication
-                                    
-      end
     end #self.included
     
     module ClassMethods
@@ -48,4 +44,4 @@
     end #InstanceMethods
     
   end #UserPublicationsPatch
-end #RedmineBibliography
\ No newline at end of file
+end #RedmineBibliography