app/models/reserve.rb in enju_circulation-0.3.11 vs app/models/reserve.rb in enju_circulation-0.4.0.beta.1

- old
+ new

@@ -1,10 +1,10 @@ class Reserve < ApplicationRecord include Statesman::Adapters::ActiveRecordQueries scope :hold, -> { where('item_id IS NOT NULL') } scope :not_hold, -> { where(item_id: nil) } - scope :waiting, -> {not_in_state(:completed, :canceled, :expired).where('canceled_at IS NULL AND (expired_at > ? OR expired_at IS NULL)', Time.zone.now).order('reserves.id DESC')} + scope :waiting, -> {not_in_state(:completed, :expired, :retained).where('canceled_at IS NULL AND (expired_at > ? OR expired_at IS NULL)', Time.zone.now).order('reserves.id DESC')} scope :retained, -> {in_state(:retained).where('retained_at IS NOT NULL')} scope :completed, -> {in_state(:completed).where('checked_out_at IS NOT NULL')} scope :canceled, -> {in_state(:canceled).where('canceled_at IS NOT NULL')} scope :postponed, -> {in_state(:postponed).where('postponed_at IS NOT NULL')} scope :will_expire_retained, lambda {|datetime| in_state(:retained).where('checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ?', datetime).order('expired_at')} @@ -369,11 +369,11 @@ ) save! end def manifestation_must_include_item - if manifestation && item && !completed? + if item_id.present? && !completed? errors[:base] << I18n.t('reserve.invalid_item') unless manifestation.items.include?(item) end end if defined?(EnjuInterLibraryLoan) @@ -402,12 +402,12 @@ # created_at :datetime # updated_at :datetime # canceled_at :datetime # expired_at :datetime # deleted_at :datetime -# expiration_notice_to_patron :boolean default("0") -# expiration_notice_to_library :boolean default("0") +# expiration_notice_to_patron :boolean default(FALSE) +# expiration_notice_to_library :boolean default(FALSE) # pickup_location_id :integer # retained_at :datetime # postponed_at :datetime -# lock_version :integer default("0"), not null +# lock_version :integer default(0), not null #