diff vendor/plugins/redmine_bibliography/app/models/authorship.rb @ 1111:7d62d2f497c5 bibplugin_bibtex

adds all the necessary hidden fieds; associates authors, users and publications. Known issues associating publications, authors and users.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 07 Dec 2012 14:39:38 +0000
parents b1debf464389
children 212b72b966ff
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb	Thu Dec 06 21:45:34 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb	Fri Dec 07 14:39:38 2012 +0000
@@ -1,18 +1,20 @@
 class Authorship < ActiveRecord::Base
-  unloadable 
-  
+  unloadable
+
   belongs_to :author
   belongs_to :publication
-  
+
   accepts_nested_attributes_for :author
   accepts_nested_attributes_for :publication
 
   validates_presence_of :name_on_paper
-  
+
   attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results
-  before_save :associate_author_user
 
-  named_scope :like_unique, lambda {|q| 
+  # todo: too much logic here
+  #  before_save :associate_author_user
+
+  named_scope :like_unique, lambda {|q|
     s = "%#{q.to_s.strip.downcase}%"
     {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
      :order => 'name_on_paper',
@@ -20,27 +22,27 @@
     }
   }
 
-  named_scope :like, lambda {|q| 
+  named_scope :like, lambda {|q|
     s = "%#{q.to_s.strip.downcase}%"
     {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
      :order => 'name_on_paper'
     }
   }
-  
+
   def name
     return self.name_on_paper
   end
-  
+
   def <=>(authorship)
     name.downcase <=> authorship.name.downcase
   end
-    
+
   def mail
     return self.email
   end
-  
-  protected 
-  def associate_author_user 
+
+  protected
+  def associate_author_user
     case self.identify_author
       when "no"
         author = Author.new
@@ -66,6 +68,6 @@
             self.author_id = object.author.id
           end
         end
-    end      
+    end
   end
 end