shop_bunny 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/app/models/coupon.rb
CHANGED
|
@@ -11,7 +11,7 @@ class Coupon < ActiveRecord::Base
|
|
|
11
11
|
|
|
12
12
|
# TODO Add self destruction when coupon has expired?
|
|
13
13
|
|
|
14
|
-
scope :valid, lambda {{:conditions => ['(coupons.valid_from IS NULL OR coupons.valid_from <= ?) AND (coupons.valid_until IS NULL OR coupons.valid_until >= ?)', Time.now, Time.now]}}
|
|
14
|
+
scope :valid, lambda {{:conditions => ['(coupons.valid_from IS NULL OR coupons.valid_from <= ?) AND (coupons.valid_until IS NULL OR coupons.valid_until >= ?) AND coupons.active = ?', Time.now, Time.now, true]}}
|
|
15
15
|
scope :automatically_added_over, lambda {|value| {:conditions => ['value_of_automatic_add <= ?', value]}}
|
|
16
16
|
|
|
17
17
|
def expired?
|
|
@@ -26,6 +26,10 @@ class Coupon < ActiveRecord::Base
|
|
|
26
26
|
def has_expired?
|
|
27
27
|
Time.now > self.valid_until if self.valid_until
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
def redeemable?
|
|
31
|
+
!not_yet_valid? && !has_expired? && active?
|
|
32
|
+
end
|
|
29
33
|
|
|
30
34
|
protected
|
|
31
35
|
def touch_cart
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shop_bunny
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 55
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 8
|
|
9
|
-
-
|
|
10
|
-
version: 0.8.
|
|
9
|
+
- 4
|
|
10
|
+
version: 0.8.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- kopfmaschine.com
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-
|
|
18
|
+
date: 2011-11-24 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|
|
@@ -47,6 +47,7 @@ files:
|
|
|
47
47
|
- app/models/coupon_use.rb
|
|
48
48
|
- db/migrate/20101125140137_add_value_of_automatic_add_to_coupons.rb
|
|
49
49
|
- db/migrate/20110821124655_add_max_uses_to_coupon.rb
|
|
50
|
+
- db/migrate/20111123234953_add_active_flag_to_coupon.rb
|
|
50
51
|
- db/migrate/20110202235446_add_raw_item_to_cart_items.rb
|
|
51
52
|
- db/migrate/20110203005514_remove_item_id_from_cart_items.rb
|
|
52
53
|
- db/migrate/20100902115757_create_cart_items.rb
|