app/models/item.rb in enju_biblio-0.1.0.pre15 vs app/models/item.rb in enju_biblio-0.1.0.pre16

- old
+ new

@@ -4,11 +4,10 @@ :checkout_type_id, :shelf_id, :include_supplements, :note, :url, :price, :acquired_at, :bookstore_id, :missing_since, :budget_type_id, :manifestation_id, :library_id, :required_role_id #,:exemplify_attributes scope :on_shelf, where('shelf_id != 1') scope :on_web, where(:shelf_id => 1) - scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)} has_one :exemplify, :dependent => :destroy has_one :manifestation, :through => :exemplify has_many :owns has_many :patrons, :through => :owns delegate :display_name, :to => :shelf, :prefix => true @@ -16,11 +15,10 @@ has_many :donates has_many :donors, :through => :donates, :source => :patron belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id', :validate => true has_one :resource_import_result belongs_to :budget_type - has_one :accept #accepts_nested_attributes_for :exemplify #before_save :create_manifestation validates_associated :bookstore validates :manifestation_id, :presence => true, :on => :create @@ -100,38 +98,14 @@ def publisher manifestation.try(:publisher) end - if defined?(EnjuLibrary) - belongs_to :shelf, :counter_cache => true, :validate => true - validates_associated :shelf - - searchable do - string :library do - shelf.library.name if shelf - end - end - - def shelf_name - shelf.name - end - end - - def hold?(library) - return true if self.shelf.library == library - false - end - def owned(patron) owns.where(:patron_id => patron.id).first end - def library_url - "#{LibraryGroup.site_config.url}libraries/#{self.shelf.library.name}" - end - def manifestation_url Addressable::URI.parse("#{LibraryGroup.site_config.url}manifestations/#{self.manifestation.id}").normalize.to_s if self.manifestation end def deletable? @@ -147,9 +121,36 @@ end def create_manifestation if manifestation_id self.manifestation = Manifestation.find(manifestation_id) + end + end + + if defined?(EnjuLibrary) + has_one :accept + scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)} + + belongs_to :shelf, :counter_cache => true, :validate => true + validates_associated :shelf + + searchable do + string :library do + shelf.library.name if shelf + end + end + + def shelf_name + shelf.name + end + + def hold?(library) + return true if self.shelf.library == library + false + end + + def library_url + "#{LibraryGroup.site_config.url}libraries/#{self.shelf.library.name}" end end end # == Schema Information