spree_promo 0.50.4 → 0.60.0.RC1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,26 @@
1
1
  class Admin::PromotionRulesController < Admin::BaseController
2
- resource_controller
3
- belongs_to :promotion
4
-
5
- create.response do |wants|
6
- wants.html { redirect_to edit_admin_promotion_path(parent_object) }
7
- wants.js { render :action => 'create', :layout => false}
8
- end
9
- destroy.response do |wants|
10
- wants.html { redirect_to edit_admin_promotion_path(parent_object) }
11
- wants.js { render :action => 'destroy', :layout => false}
2
+ def create
3
+ @promotion = Promotion.find(params[:promotion_id])
4
+ @promotion_rule = params[:promotion_rule][:type].constantize.new(params[:promotion_rule])
5
+ @promotion_rule.promotion = @promotion
6
+ if @promotion_rule.save
7
+ flash[:notice] = I18n.t(:successfully_created, :resource => I18n.t(:promotion_rule))
8
+ end
9
+ respond_to do |format|
10
+ format.html { redirect_to edit_admin_promotion_path(@promotion)}
11
+ format.js { render :layout => false }
12
+ end
12
13
  end
13
-
14
- private
15
-
16
- def build_object
17
- return @object if @object.present?
18
- if params[:promotion_rule] && params[:promotion_rule][:type]
19
- @object = params[:promotion_rule][:type].constantize.new(object_params)
20
- @object.promotion = parent_object
21
- else
22
- @object = end_of_association_chain.build(object_params)
23
- end
24
- @object
14
+
15
+ def destroy
16
+ @promotion = Promotion.find(params[:promotion_id])
17
+ @promotion_rule = @promotion.promotion_rules.find(params[:id])
18
+ if @promotion_rule.destroy
19
+ flash[:notice] = I18n.t(:successfully_removed, :resource => I18n.t(:promotion_rule))
25
20
  end
26
-
21
+ respond_to do |format|
22
+ format.html { redirect_to edit_admin_promotion_path(@promotion)}
23
+ format.js { render :layout => false }
24
+ end
25
+ end
27
26
  end
@@ -1,15 +1,18 @@
1
- class Admin::PromotionsController < Admin::BaseController
2
- resource_controller
1
+ class Admin::PromotionsController < Admin::ResourceController
3
2
  before_filter :load_data
4
3
 
5
- update.wants.html { redirect_to edit_object_url }
6
- create.wants.html { redirect_to edit_object_url }
7
- destroy.success.wants.js { render_js_for_destroy }
4
+ protected
8
5
 
9
- private
10
- def build_object
11
- @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
12
- @object.calculator = params[:promotion][:calculator_type].constantize.new if params[:promotion]
6
+ def build_resource
7
+ @promotion = Promotion.new(params[:promotion])
8
+ if params[:promotion] && params[:promotion][:calculator_type]
9
+ @promotion.calculator = params[:promotion][:calculator_type].constantize.new
10
+ end
11
+ @promotion
12
+ end
13
+
14
+ def location_after_save
15
+ edit_admin_promotion_url(@promotion)
13
16
  end
14
17
 
15
18
  def load_data
@@ -0,0 +1,10 @@
1
+ OrdersController.class_eval do
2
+ after_filter :clear_promotions
3
+
4
+ private
5
+ def clear_promotions
6
+ current_order.promotion_credits.destroy_all if current_order
7
+ end
8
+
9
+ end
10
+
@@ -1,6 +1,6 @@
1
- jQuery('#rules').append('<%= escape_javascript( render(:partial => 'admin/promotions/promotion_rule', :object => object) ) %>');
2
- jQuery('#<%= dom_id object %>').hide();
3
- jQuery('#<%= dom_id object %>').fadeIn();
1
+ jQuery('#rules').append('<%= escape_javascript( render(:partial => 'admin/promotions/promotion_rule', :object => @promotion_rule) ) %>');
2
+ jQuery('#<%= dom_id @promotion_rule %>').hide();
3
+ jQuery('#<%= dom_id @promotion_rule %>').fadeIn();
4
4
  initProductRuleSourceField();
5
- jQuery('#<%= dom_id object %> .tokeninput.products').productPicker();
6
- jQuery('#<%= dom_id object %> .tokeninput.users').userPicker();
5
+ jQuery('#<%= dom_id @promotion_rule %> .tokeninput.products').productPicker();
6
+ jQuery('#<%= dom_id @promotion_rule %> .tokeninput.users').userPicker();
@@ -1 +1 @@
1
- jQuery('#<%= dom_id object %>').fadeOut().remove();
1
+ jQuery('#<%= dom_id @promotion_rule %>').fadeOut().remove();
@@ -18,6 +18,7 @@ en:
18
18
  may_be_combined_with_other_promotions: May be combined with other promotions
19
19
  new_promotion: New Promotion
20
20
  no_rules_added: No rules added
21
+ promotion: Promotion
21
22
  promotions: Promotions
22
23
  promotion_form:
23
24
  match_policies:
@@ -39,7 +40,7 @@ en:
39
40
  description: Must be the customer's first order
40
41
  product_rule:
41
42
  choose_products: Choose products
42
- label: "Order must contain {{select}} of these products"
43
+ label: "Order must contain %{select} of these products"
43
44
  match_any: at least one
44
45
  match_all: all
45
46
  product_source:
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_promo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 223
5
- prerelease:
4
+ hash: 11094359
5
+ prerelease: 7
6
6
  segments:
7
7
  - 0
8
- - 50
9
- - 4
10
- version: 0.50.4
8
+ - 60
9
+ - 0
10
+ - RC
11
+ - 1
12
+ version: 0.60.0.RC1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David North
@@ -15,24 +17,27 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-10-21 00:00:00 Z
20
+ date: 2011-05-03 00:00:00 -04:00
21
+ default_executable:
19
22
  dependencies:
20
23
  - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ name: spree_core
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
22
27
  none: false
23
28
  requirements:
24
29
  - - "="
25
30
  - !ruby/object:Gem::Version
26
- hash: 223
31
+ hash: 11094359
27
32
  segments:
28
33
  - 0
29
- - 50
30
- - 4
31
- version: 0.50.4
32
- requirement: *id001
34
+ - 60
35
+ - 0
36
+ - RC
37
+ - 1
38
+ version: 0.60.0.RC1
33
39
  type: :runtime
34
- prerelease: false
35
- name: spree_core
40
+ version_requirements: *id001
36
41
  description: Required dependancy for Spree
37
42
  email: david@railsdog.com
38
43
  executables: []
@@ -44,6 +49,7 @@ extra_rdoc_files: []
44
49
  files:
45
50
  - app/controllers/admin/promotion_rules_controller.rb
46
51
  - app/controllers/admin/promotions_controller.rb
52
+ - app/controllers/orders_controller_decorator.rb
47
53
  - app/models/calculator/free_shipping.rb
48
54
  - app/models/promotion/rules/first_order.rb
49
55
  - app/models/promotion/rules/item_total.rb
@@ -83,6 +89,7 @@ files:
83
89
  - db/migrate/20100923095305_update_calculable_type_for_promotions.rb
84
90
  - public/javascripts/admin/promotions.js
85
91
  - public/stylesheets/admin/promotions.css
92
+ has_rdoc: true
86
93
  homepage: http://spreecommerce.com
87
94
  licenses: []
88
95
 
@@ -105,16 +112,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
112
  required_rubygems_version: !ruby/object:Gem::Requirement
106
113
  none: false
107
114
  requirements:
108
- - - ">="
115
+ - - ">"
109
116
  - !ruby/object:Gem::Version
110
- hash: 3
117
+ hash: 25
111
118
  segments:
112
- - 0
113
- version: "0"
119
+ - 1
120
+ - 3
121
+ - 1
122
+ version: 1.3.1
114
123
  requirements:
115
124
  - none
116
125
  rubyforge_project: spree_promo
117
- rubygems_version: 1.8.10
126
+ rubygems_version: 1.4.2
118
127
  signing_key:
119
128
  specification_version: 3
120
129
  summary: Promotion functionality for use with Spree.