spree_promo 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/app/assets/javascripts/admin/promotions.js +1 -1
- data/app/controllers/spree/checkout_controller_decorator.rb +4 -1
- data/app/models/spree/promotion.rb +9 -6
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_user.html.erb +2 -1
- metadata +34 -72
data/LICENSE
CHANGED
@@ -3,7 +3,7 @@ var initProductRuleSourceField = function(){
|
|
3
3
|
|
4
4
|
$products_source_field = jQuery('.products_rule_products_source_field input');
|
5
5
|
$products_source_field.click(function() {
|
6
|
-
$rule_container = jQuery(this).parents('.
|
6
|
+
$rule_container = jQuery(this).parents('.promotion_rule');
|
7
7
|
if(this.checked){
|
8
8
|
if(this.value == 'manual'){
|
9
9
|
$rule_container.find('.products_rule_products').show();
|
@@ -7,7 +7,10 @@ Spree::CheckoutController.class_eval do
|
|
7
7
|
if @order.coupon_code.present?
|
8
8
|
# Promotion codes are stored in the preference table
|
9
9
|
# Therefore we need to do a lookup there and find if one exists
|
10
|
-
|
10
|
+
#
|
11
|
+
# TODO: The ActiveRecord::Base.connection.quote_column_name stuff is a bit long...
|
12
|
+
# TODO: Is there a better way to do that?
|
13
|
+
if Spree::Preference.where(:value => @order.coupon_code).where("#{ActiveRecord::Base.connection.quote_column_name("key")} LIKE 'spree/promotion/code/%'").present?
|
11
14
|
fire_event('spree.checkout.coupon_code_added', :coupon_code => @order.coupon_code)
|
12
15
|
# If it doesn't exist, raise an error!
|
13
16
|
# Giving them another chance to enter a valid coupon code
|
@@ -52,7 +52,7 @@ module Spree
|
|
52
52
|
def advertised
|
53
53
|
#TODO this is broken because the new preferences aren't a direct relationship returning
|
54
54
|
#all for now
|
55
|
-
|
55
|
+
scoped
|
56
56
|
#includes(:stored_preferences)
|
57
57
|
#includes(:stored_preferences).where(:spree_preferences => {:name => 'advertise', :value => '1'})
|
58
58
|
end
|
@@ -79,18 +79,21 @@ module Spree
|
|
79
79
|
# Whether the promotion is eligible for this particular order.
|
80
80
|
def eligible?(order, options = {})
|
81
81
|
return false if expired? || usage_limit_exceeded?(order)
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
|
83
|
+
event_code = options[:coupon_code].to_s.strip.downcase
|
84
|
+
return false unless event_code == self.code.to_s.strip.downcase
|
85
|
+
|
85
86
|
rules_are_eligible?(order, options)
|
86
87
|
end
|
87
88
|
|
88
89
|
def rules_are_eligible?(order, options = {})
|
89
90
|
return true if rules.none?
|
91
|
+
|
92
|
+
eligible = lambda { |r| r.eligible?(order, options) }
|
90
93
|
if match_policy == 'all'
|
91
|
-
rules.all?
|
94
|
+
rules.all?(&eligible)
|
92
95
|
else
|
93
|
-
rules.any?
|
96
|
+
rules.any?(&eligible)
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<fieldset id="action_fields">
|
2
2
|
<legend><%= t(:promotion_actions) %></legend>
|
3
3
|
|
4
|
-
<%= form_for @promotion, :url => spree.admin_promotion_path(@promotion), :
|
4
|
+
<%= form_for @promotion, :url => spree.admin_promotion_path(@promotion), :method => :put do |f| %>
|
5
5
|
<div id="actions" class="filter_list">
|
6
6
|
<% if @promotion.actions.any? %>
|
7
7
|
<%#= render :partial => 'promotion_action', :collection => @promotion.actions, :locals => {:f => f} %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<fieldset id="rule_fields">
|
2
2
|
<legend><%= t(:rules) %></legend>
|
3
3
|
|
4
|
-
<%= form_for @promotion, :url => object_url, :
|
4
|
+
<%= form_for @promotion, :url => object_url, :method => :put do |f| %>
|
5
5
|
<p>
|
6
6
|
<% Spree::Promotion::MATCH_POLICIES.each do |policy| %>
|
7
7
|
<label><%= f.radio_button :preferred_match_policy, policy %> <%= t "promotion_form.match_policies.#{policy}" %></label>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h1><%= t(:editing_promotion) %></h1>
|
2
2
|
|
3
|
-
<%= form_for @promotion, :url => object_url, :
|
3
|
+
<%= form_for @promotion, :url => object_url, :method => :put do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
5
|
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
|
6
6
|
<% end %>
|
@@ -2,6 +2,7 @@
|
|
2
2
|
<label>
|
3
3
|
<%= t('user_rule.choose_users') %><br />
|
4
4
|
<% user_names_hash = promotion_rule.users.inject({}){|memo,item| memo[item.id] = item.email; memo} %>
|
5
|
-
|
5
|
+
<% user_rules = promotion_rule.users.collect { |u| { :id => u.id, :name => u.email } } %>
|
6
|
+
<input type="text" name="<%= param_prefix %>[user_ids_string]" value="<%= promotion_rule.user_ids_string %>" class="tokeninput users" data-names='<%= user_names_hash.to_json %>' data-pre='<%= user_rules.to_json %>'/>
|
6
7
|
</label>
|
7
8
|
</p>
|
metadata
CHANGED
@@ -1,69 +1,44 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_promo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.rc2
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
- rc
|
11
|
-
- 1
|
12
|
-
version: 1.0.0.rc1
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- David North
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
date: 2012-01-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: spree_core
|
16
|
+
requirement: &70362724534240 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
- 0
|
33
|
-
- rc
|
34
|
-
- 1
|
35
|
-
version: 1.0.0.rc1
|
36
|
-
requirement: *id001
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0.rc2
|
37
22
|
type: :runtime
|
38
23
|
prerelease: false
|
39
|
-
|
40
|
-
- !ruby/object:Gem::Dependency
|
41
|
-
|
24
|
+
version_requirements: *70362724534240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: spree_auth
|
27
|
+
requirement: &70362724533380 !ruby/object:Gem::Requirement
|
42
28
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
segments:
|
48
|
-
- 1
|
49
|
-
- 0
|
50
|
-
- 0
|
51
|
-
- rc
|
52
|
-
- 1
|
53
|
-
version: 1.0.0.rc1
|
54
|
-
requirement: *id002
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0.rc2
|
55
33
|
type: :runtime
|
56
34
|
prerelease: false
|
57
|
-
|
35
|
+
version_requirements: *70362724533380
|
58
36
|
description: Required dependency for Spree
|
59
|
-
email: david@
|
37
|
+
email: david@spreecommerce.com
|
60
38
|
executables: []
|
61
|
-
|
62
39
|
extensions: []
|
63
|
-
|
64
40
|
extra_rdoc_files: []
|
65
|
-
|
66
|
-
files:
|
41
|
+
files:
|
67
42
|
- LICENSE
|
68
43
|
- app/assets/javascripts/admin/promotions.js
|
69
44
|
- app/assets/javascripts/admin/spree_promo.js
|
@@ -140,35 +115,23 @@ files:
|
|
140
115
|
- db/migrate/20111013155037_namespace_promo_tables.rb
|
141
116
|
homepage: http://spreecommerce.com
|
142
117
|
licenses: []
|
143
|
-
|
144
118
|
post_install_message:
|
145
119
|
rdoc_options: []
|
146
|
-
|
147
|
-
require_paths:
|
120
|
+
require_paths:
|
148
121
|
- lib
|
149
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
123
|
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
hash: 57
|
155
|
-
segments:
|
156
|
-
- 1
|
157
|
-
- 8
|
158
|
-
- 7
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
159
127
|
version: 1.8.7
|
160
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
129
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
hash: 25
|
166
|
-
segments:
|
167
|
-
- 1
|
168
|
-
- 3
|
169
|
-
- 1
|
130
|
+
requirements:
|
131
|
+
- - ! '>'
|
132
|
+
- !ruby/object:Gem::Version
|
170
133
|
version: 1.3.1
|
171
|
-
requirements:
|
134
|
+
requirements:
|
172
135
|
- none
|
173
136
|
rubyforge_project:
|
174
137
|
rubygems_version: 1.8.10
|
@@ -176,4 +139,3 @@ signing_key:
|
|
176
139
|
specification_version: 3
|
177
140
|
summary: Promotion functionality for use with Spree.
|
178
141
|
test_files: []
|
179
|
-
|