shop_bunny 0.7.5 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,13 @@ class CartItem < ActiveRecord::Base
37
37
  @parsed_raw_item
38
38
  end
39
39
 
40
+ def as_json(options={})
41
+ {
42
+ :quantity => quantity,
43
+ :id => item.id
44
+ }
45
+ end
46
+
40
47
  private
41
48
 
42
49
  def set_default_quantity
@@ -0,0 +1,9 @@
1
+ class AddMaxUsesToCoupon < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :coupons, :max_uses, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :coupons, :max_uses
8
+ end
9
+ end
@@ -156,7 +156,7 @@ module ShopBunny
156
156
  def update_coupons
157
157
  Array(@coupon_code).each { |code|
158
158
  coupon = Coupon.find_by_code(code)
159
- coupons << coupon if coupon && !coupons.include?(coupon)
159
+ coupons << coupon if coupon && !coupons.include?(coupon) && (coupon.max_uses.nil? || coupon.max_uses >= coupon.coupon_uses.count)
160
160
  }
161
161
  end
162
162
 
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: 9
5
- prerelease: false
4
+ hash: 59
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 5
10
- version: 0.7.5
8
+ - 8
9
+ - 2
10
+ version: 0.8.2
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-04-18 00:00:00 -07:00
18
+ date: 2011-08-21 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -30,34 +30,35 @@ extra_rdoc_files: []
30
30
 
31
31
  files:
32
32
  - lib/shop_bunny.rb
33
- - lib/shop_bunny/cart_module.rb
34
- - lib/shop_bunny/engine.rb
35
- - lib/shop_bunny/cart_controller_module.rb
36
- - lib/shop_bunny/shipping_cost_calculator.rb
37
33
  - lib/generators/shop_bunny/install_generator.rb
38
34
  - lib/generators/shop_bunny/templates/shopbunny_controller_template.rb
39
35
  - lib/generators/shop_bunny/templates/shopbunny_model_template.rb
36
+ - lib/shop_bunny/cart_controller_module.rb
37
+ - lib/shop_bunny/cart_module.rb
38
+ - lib/shop_bunny/engine.rb
39
+ - lib/shop_bunny/shipping_cost_calculator.rb
40
+ - app/controllers/application_controller.rb
41
+ - app/controllers/carts_controller.rb
40
42
  - app/views/carts/show.html.erb
41
- - app/models/coupon_use.rb
42
- - app/models/coupon.rb
43
- - app/models/cart.rb
44
43
  - app/models/item.rb
45
44
  - app/models/cart_item.rb
46
- - app/controllers/application_controller.rb
47
- - app/controllers/carts_controller.rb
48
- - db/migrate/20100915093821_create_coupon_uses.rb
45
+ - app/models/cart.rb
46
+ - app/models/coupon.rb
47
+ - app/models/coupon_use.rb
49
48
  - db/migrate/20101125140137_add_value_of_automatic_add_to_coupons.rb
50
- - db/migrate/20100915091059_create_coupons.rb
49
+ - db/migrate/20110821124655_add_max_uses_to_coupon.rb
50
+ - db/migrate/20110202235446_add_raw_item_to_cart_items.rb
51
+ - db/migrate/20110203005514_remove_item_id_from_cart_items.rb
52
+ - db/migrate/20100902115757_create_cart_items.rb
51
53
  - db/migrate/20100915162029_remove_owner_id_from_carts.rb
54
+ - db/migrate/20100916194407_set_default_column_value_for_cart_items_quantity.rb
55
+ - db/migrate/20100915091059_create_coupons.rb
52
56
  - db/migrate/20101125151017_change_valid_from_and_until_to_datetime_on_coupons.rb
53
57
  - db/migrate/20100902115627_create_carts.rb
54
- - db/migrate/20100916194407_set_default_column_value_for_cart_items_quantity.rb
55
- - db/migrate/20110203005514_remove_item_id_from_cart_items.rb
56
- - db/migrate/20110202235446_add_raw_item_to_cart_items.rb
58
+ - db/migrate/20100915093821_create_coupon_uses.rb
57
59
  - db/migrate/20100915073016_create_items.rb
58
- - db/migrate/20100902115757_create_cart_items.rb
59
- - config/initializers/shop_bunny.rb
60
60
  - config/initializers/machinist.rb
61
+ - config/initializers/shop_bunny.rb
61
62
  - config/initializers/add_cart_finder_to_controllers.rb
62
63
  - config/routes.rb
63
64
  has_rdoc: true
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
93
  requirements: []
93
94
 
94
95
  rubyforge_project:
95
- rubygems_version: 1.3.7
96
+ rubygems_version: 1.6.2
96
97
  signing_key:
97
98
  specification_version: 3
98
99
  summary: A shop template for your needs