enju_circulation 0.0.65 → 0.0.66

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ class Checkin < ActiveRecord::Base
10
10
  validates_uniqueness_of :item_id, :scope => :basket_id, :message => I18n.t('checkin.already_checked_in')
11
11
  validates_presence_of :item_id, :message => I18n.t('checkin.item_not_found')
12
12
  validates_presence_of :basket_id
13
+ validate :available_for_checkin?, :on => :create
13
14
 
14
15
  attr_accessor :item_identifier
15
16
 
@@ -17,6 +18,17 @@ class Checkin < ActiveRecord::Base
17
18
  10
18
19
  end
19
20
 
21
+ def available_for_checkin?
22
+ if item.blank?
23
+ errors[:base] << I18n.t('checkin.item_not_found')
24
+ return
25
+ end
26
+
27
+ if basket.items.where('item_id = ?', item.id).first
28
+ errors[:base] << I18n.t('checkin.already_checked_in')
29
+ end
30
+ end
31
+
20
32
  def item_checkin(current_user)
21
33
  message = ''
22
34
  Checkin.transaction do
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.65"
2
+ VERSION = "0.0.66"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_circulation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.65
4
+ version: 0.0.66
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-23 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails