Sha256: b5c0388e794021d38eed34d2d9fbe81e6d4d12d45116df07dbe02511be4a3d77

Contents?: true

Size: 975 Bytes

Versions: 10

Compression:

Stored size: 975 Bytes

Contents

class Accept < ActiveRecord::Base
  attr_accessible :item_identifier, :librarian_id, :item_id
  default_scope :order => 'accepts.id DESC'
  belongs_to :basket
  belongs_to :item
  belongs_to :librarian, :class_name => 'User'

  validates_uniqueness_of :item_id, :message => I18n.t('accept.already_accepted')
  validates_presence_of :item_id, :message => I18n.t('accept.item_not_found')
  validates_presence_of :basket_id

  before_save :accept!, :on => :create

  attr_accessor :item_identifier

  paginates_per 10

  def accept!
    if defined?(EnjuCirculation)
      item.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
    end
    item.save(:validate => false)
  end
end
# == Schema Information
#
# Table name: accepts
#
#  id           :integer         not null, primary key
#  basket_id    :integer
#  item_id      :integer
#  librarian_id :integer
#  created_at   :datetime        not null
#  updated_at   :datetime        not null
#

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre10 app/models/accept.rb
enju_biblio-0.1.0.pre9 app/models/accept.rb
enju_biblio-0.1.0.pre8 app/models/accept.rb
enju_biblio-0.1.0.pre7 app/models/accept.rb
enju_biblio-0.1.0.pre6 app/models/accept.rb
enju_biblio-0.1.0.pre5 app/models/accept.rb
enju_biblio-0.1.0.pre4 app/models/accept.rb
enju_biblio-0.1.0.pre3 app/models/accept.rb
enju_biblio-0.1.0.pre2 app/models/accept.rb
enju_biblio-0.1.0.pre app/models/accept.rb