spree_promo 1.1.6 → 1.2.0.rc1

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.
@@ -1,6 +1,6 @@
1
1
  var initProductActions = function(){
2
2
 
3
- $("#add_product_name").product_autocomplete();
3
+ $(".product_autocomplete").product_autocomplete();
4
4
 
5
5
  $('.calculator-fields').each(function(){
6
6
  var $fields_container = $(this);
@@ -1,3 +1,2 @@
1
1
  //= require admin/spree_core
2
- //= require admin/spree_auth
3
2
  //= require_tree .
@@ -1,2 +1 @@
1
1
  //= require store/spree_core
2
- //= require store/spree_auth
@@ -1,5 +1,4 @@
1
1
  /*
2
2
  *= require admin/spree_core
3
- *= require admin/spree_auth
4
3
  *= require admin/promotions
5
4
  */
@@ -1,4 +1,17 @@
1
1
  /*
2
2
  *= require store/spree_core
3
- *= require store/spree_auth
3
+ *= require_self
4
4
  */
5
+
6
+ #update-cart .coupon-code-field {
7
+ /* yes, this is ugly... */
8
+ margin-top: -42px !important;
9
+ }
10
+
11
+ @media only screen and (max-width: 767px) {
12
+ #empty-cart,
13
+ #update-cart .coupon-code-field {
14
+ /* yes, this is ugly... */
15
+ margin-top: 0 !important;
16
+ }
17
+ }
@@ -0,0 +1,30 @@
1
+ Spree::OrdersController.class_eval do
2
+
3
+ def update
4
+ @order = current_order
5
+ if @order.update_attributes(params[:order])
6
+ if @order.coupon_code.present?
7
+ if apply_coupon_code
8
+ flash[:notice] = t(:coupon_code_applied)
9
+ else
10
+ flash[:error] = t(:promotion_not_found)
11
+ render :edit and return
12
+ end
13
+ end
14
+ @order.line_items = @order.line_items.select {|li| li.quantity > 0 }
15
+ fire_event('spree.order.contents_changed')
16
+ respond_with(@order) { |format| format.html { redirect_to cart_path } }
17
+ else
18
+ respond_with(@order)
19
+ end
20
+ end
21
+
22
+ def apply_coupon_code
23
+ return if @order.coupon_code.blank?
24
+ if Spree::Promotion.exists?(:code => @order.coupon_code)
25
+ fire_event('spree.checkout.coupon_code_added', :coupon_code => @order.coupon_code)
26
+ true
27
+ end
28
+ end
29
+
30
+ end
@@ -23,8 +23,4 @@ Spree::Order.class_eval do
23
23
  end
24
24
  alias_method_chain :update_adjustments, :promotion_limiting
25
25
  end
26
-
27
- def promo_total
28
- adjustments.promotion.map(&:amount).sum
29
- end
30
26
  end
@@ -1,5 +1,5 @@
1
1
  Spree::Product.class_eval do
2
- has_and_belongs_to_many :promotion_rules, :join_table => 'spree_products_promotion_rules'
2
+ has_and_belongs_to_many :promotion_rules, :join_table => :spree_products_promotion_rules
3
3
 
4
4
  def possible_promotions
5
5
  all_rules = promotion_rules
@@ -6,11 +6,11 @@ module Spree
6
6
  Activator.event_names << 'spree.checkout.coupon_code_added'
7
7
  Activator.event_names << 'spree.content.visited'
8
8
 
9
- has_many :promotion_rules, :foreign_key => 'activator_id', :autosave => true, :dependent => :destroy
9
+ has_many :promotion_rules, :foreign_key => :activator_id, :autosave => true, :dependent => :destroy
10
10
  alias_method :rules, :promotion_rules
11
11
  accepts_nested_attributes_for :promotion_rules
12
12
 
13
- has_many :promotion_actions, :foreign_key => 'activator_id', :autosave => true, :dependent => :destroy
13
+ has_many :promotion_actions, :foreign_key => :activator_id, :autosave => true, :dependent => :destroy
14
14
  alias_method :actions, :promotion_actions
15
15
  accepts_nested_attributes_for :promotion_actions
16
16
 
@@ -45,4 +45,4 @@ module Spree
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -2,7 +2,7 @@ module Spree
2
2
  class Promotion
3
3
  module Actions
4
4
  class CreateLineItems < PromotionAction
5
- has_many :promotion_action_line_items, :foreign_key => 'promotion_action_id'
5
+ has_many :promotion_action_line_items, :foreign_key => :promotion_action_id
6
6
 
7
7
  attr_accessor :line_items_string
8
8
 
@@ -33,4 +33,4 @@ module Spree
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -4,8 +4,8 @@ module Spree
4
4
  class User < PromotionRule
5
5
  attr_accessible :user_ids_string
6
6
 
7
- belongs_to :user, :class_name => "Spree::User"
8
- has_and_belongs_to_many :users, :class_name => '::Spree::User', :join_table => 'spree_promotion_rules_users', :foreign_key => 'promotion_rule_id'
7
+ belongs_to :user, :class_name => Spree.user_class.to_s
8
+ has_and_belongs_to_many :users, :class_name => Spree.user_class.to_s, :join_table => 'spree_promotion_rules_users', :foreign_key => 'promotion_rule_id'
9
9
 
10
10
  def eligible?(order, options = {})
11
11
  users.none? or users.include?(order.user)
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/orders/edit",
2
+ :name => "promo_cart_coupon_code_field",
3
+ :insert_after => "[data-hook='cart_buttons']",
4
+ :partial => "spree/orders/coupon_code_field",
5
+ :disabled => false,
6
+ :original => "c11d9a1996fb86e992aba19035074cf5f688dea2")
@@ -5,4 +5,5 @@ initProductActions();
5
5
  $('#<%= dom_id @promotion_action %>').hide();
6
6
  $('#<%= dom_id @promotion_action %>').fadeIn();
7
7
  $('#<%= dom_id @promotion_action %> .tokeninput.products').productPicker();
8
+ $('.product_autocomplete').product_autocomplete();
8
9
 
@@ -1,17 +1,4 @@
1
- <% if @promotion && (@promotion.errors.any? || @promotion.rules.any? { |r| r.errors.any? }) %>
2
- <% error_group = [@promotion.errors, @promotion.rules.map(&:errors)].flatten %>
3
- <div id="errorExplanation" class="errorExplanation" data-hook>
4
- <h2><%= t(:errors_prohibited_this_record_from_being_saved, :count => error_group.count) %>:</h2>
5
- <p><%= t(:there_were_problems_with_the_following_fields) %>:</p>
6
- <ul>
7
- <% error_group.each do |errors| %>
8
- <% errors.full_messages.each do |msg| %>
9
- <li><%= msg %></li>
10
- <% end %>
11
- <% end %>
12
- </ul>
13
- </div>
14
- <% end %>
1
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @promotion } %>
15
2
  <fieldset id="general_fields">
16
3
  <legend><%= t(:general) %></legend>
17
4
  <%= f.field_container :name do %>
@@ -27,7 +27,7 @@
27
27
  <legend><%= t(:add_product) %></legend>
28
28
  <div style="float:left; width:50%; margin-right:5%;">
29
29
  <%= label_tag :add_product_name, t(:name_or_sku) %>
30
- <%= text_field_tag :add_product_name, nil, :class => 'fullwidth' %>
30
+ <%= text_field_tag :add_product_name, nil, :class => 'fullwidth product_autocomplete' %>
31
31
  <%= hidden_field_tag :add_variant_id %>
32
32
  <%= hidden_field_tag :add_line_item_variant_id %>
33
33
  </div>
@@ -1,6 +1,6 @@
1
1
  <% if Spree::Promotion.count > 0 %>
2
- <p class='field' data-hook='coupon_code'>
3
- <%= form.label :coupon_code %><br />
4
- <%= form.text_field :coupon_code %>
5
- </p>
2
+ <p>
3
+ <%= form.label :coupon_code %><br />
4
+ <%= form.text_field :coupon_code %>
5
+ </p>
6
6
  <% end %>
@@ -0,0 +1,7 @@
1
+ <% if Spree::Promotion.count > 0 %>
2
+ <div class="five columns alpha offset-by-nine coupon-code-field">
3
+ <%= order_form.label :coupon_code %><br />
4
+ <%= order_form.text_field :coupon_code, :size => 10 %>
5
+ <%= order_form.submit I18n.t(:apply) %>
6
+ </div>
7
+ <% end %>
@@ -16,6 +16,7 @@ en:
16
16
  add_rule_of_type: Add rule of type
17
17
  coupon: Coupon
18
18
  coupon_code: Coupon code
19
+ coupon_code_applied: The coupon code was successfully applied to your order.
19
20
  editing_promotion: Editing Promotion
20
21
  events:
21
22
  spree:
@@ -1,5 +1,4 @@
1
1
  require 'spree/core'
2
- require 'spree/auth'
3
2
 
4
3
  module Spree
5
4
  module Promo
@@ -7,14 +7,15 @@ module Spree
7
7
  def self.activate
8
8
  Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
9
9
  Rails.configuration.cache_classes ? require(c) : load(c)
10
- end
11
10
 
12
- # Include list of visited paths in notification payload hash
13
- Spree::Core::ControllerHelpers.class_eval do
14
- def default_notification_payload
15
- { :user => current_user, :order => current_order, :visited_paths => session[:visited_paths] }
11
+ Spree::BaseController.class_eval do
12
+ # Include list of visited paths in notification payload hash
13
+ def default_notification_payload
14
+ { :user => try_spree_current_user, :order => current_order, :visited_paths => session[:visited_paths] }
15
+ end
16
16
  end
17
17
  end
18
+
18
19
  end
19
20
 
20
21
  config.autoload_paths += %W(#{config.root}/lib)
metadata CHANGED
@@ -1,48 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_promo
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.6
4
+ version: 1.2.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - David North
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-25 00:00:00.000000000 Z
12
+ date: 2012-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- type: :runtime
16
- version_requirements: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - '='
20
- - !ruby/object:Gem::Version
21
- version: 1.1.6
22
15
  name: spree_core
23
- prerelease: false
24
16
  requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
18
  requirements:
27
19
  - - '='
28
20
  - !ruby/object:Gem::Version
29
- version: 1.1.6
30
- - !ruby/object:Gem::Dependency
21
+ version: 1.2.0.rc1
31
22
  type: :runtime
32
- version_requirements: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - '='
36
- - !ruby/object:Gem::Version
37
- version: 1.1.6
38
- name: spree_auth
39
23
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
41
25
  none: false
42
26
  requirements:
43
27
  - - '='
44
28
  - !ruby/object:Gem::Version
45
- version: 1.1.6
29
+ version: 1.2.0.rc1
46
30
  description: Required dependency for Spree
47
31
  email: david@spreecommerce.com
48
32
  executables: []
@@ -61,11 +45,11 @@ files:
61
45
  - app/controllers/spree/admin/promotions_controller.rb
62
46
  - app/controllers/spree/checkout_controller_decorator.rb
63
47
  - app/controllers/spree/content_controller_decorator.rb
48
+ - app/controllers/spree/orders_controller_decorator.rb
64
49
  - app/helpers/spree/promotion_rules_helper.rb
65
50
  - app/models/spree/adjustment_decorator.rb
66
51
  - app/models/spree/calculator/free_shipping.rb
67
52
  - app/models/spree/order_decorator.rb
68
- - app/models/spree/payment_decorator.rb
69
53
  - app/models/spree/product_decorator.rb
70
54
  - app/models/spree/promotion/actions/create_adjustment.rb
71
55
  - app/models/spree/promotion/actions/create_line_items.rb
@@ -79,6 +63,7 @@ files:
79
63
  - app/models/spree/promotion_action_line_item.rb
80
64
  - app/models/spree/promotion_rule.rb
81
65
  - app/overrides/promo_admin_tabs.rb
66
+ - app/overrides/promo_cart_coupon_code_field.rb
82
67
  - app/overrides/promo_coupon_code_field.rb
83
68
  - app/overrides/promo_product_properties.rb
84
69
  - app/views/spree/admin/promotion_actions/create.js.erb
@@ -103,6 +88,7 @@ files:
103
88
  - app/views/spree/admin/promotions/rules/_user.html.erb
104
89
  - app/views/spree/admin/promotions/rules/_user_logged_in.html.erb
105
90
  - app/views/spree/checkout/_coupon_code_field.html.erb
91
+ - app/views/spree/orders/_coupon_code_field.html.erb
106
92
  - app/views/spree/products/_promotions.html.erb
107
93
  - config/locales/en.yml
108
94
  - config/routes.rb
@@ -124,8 +110,7 @@ files:
124
110
  - db/migrate/20120119024708_create_spree_pending_promotions.rb
125
111
  - db/migrate/20120119024721_content_visited_event.rb
126
112
  homepage: http://spreecommerce.com
127
- licenses:
128
- - BSD-3
113
+ licenses: []
129
114
  post_install_message:
130
115
  rdoc_options: []
131
116
  require_paths:
@@ -139,12 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
124
  required_rubygems_version: !ruby/object:Gem::Requirement
140
125
  none: false
141
126
  requirements:
142
- - - ! '>='
127
+ - - ! '>'
143
128
  - !ruby/object:Gem::Version
144
- segments:
145
- - 0
146
- hash: -1663519733063640268
147
- version: '0'
129
+ version: 1.3.1
148
130
  requirements:
149
131
  - none
150
132
  rubyforge_project:
@@ -1,5 +0,0 @@
1
- Spree::Payment.class_eval do
2
- def promo_total
3
- order.promo_total * 100
4
- end
5
- end