spree_zoned 0.5.18 → 0.5.19

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_zoned (0.5.0)
4
+ spree_zoned (0.5.18)
5
5
  spree_core (~> 1.1.1)
6
6
 
7
7
  GEM
@@ -2,7 +2,7 @@ require 'delocalize'
2
2
 
3
3
  Spree::Admin::ProductsController.class_eval do
4
4
 
5
- before_filter :deloc_master_price
5
+ before_filter :delocSetPrice, :only => :update
6
6
 
7
7
  def deletefc
8
8
  inorout(@product.method :delfrom)
@@ -82,18 +82,23 @@ protected
82
82
 
83
83
  def inorout(m)
84
84
  country = session[:zoned] && session[:zoned][:prd_country]
85
- m.call(country.to_i) if country
85
+ m.call(country.to_i) if country && country.to_i != 0
86
86
  respond_to do |format|
87
87
  format.html { redirect_to collection_url }
88
88
  format.js { render nothing: true }
89
89
  end
90
90
  end
91
91
 
92
- def deloc_master_price
92
+ def delocSetPrice
93
93
  if params[:product] && params[:product][:price]
94
94
  params[:product][:price] = Delocalize::LocalizedNumericParser.parse(
95
95
  params[:product][:price])
96
96
  end
97
+ country = session[:zoned] && session[:zoned][:prd_country]
98
+ if country && country != 0 && params[:product] && params[:product][:price]
99
+ @product.setprice(country.to_i, BigDecimal.new(params[:product][:price]))
100
+ end
101
+ params[:product][:price] = @product.price
97
102
  end
98
103
 
99
104
  end
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ module Admin
3
+ ProductsHelper.module_eval do
4
+
5
+ def getCPrice(p)
6
+ c = session[:zoned] && session[:zoned][:prd_country]
7
+ c = c ? c.to_i : 0
8
+ return p.price if c == 0
9
+ zpl = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", p.id, c
10
+ zpl == [] ? p.price : zpl[0].cprice
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -14,9 +14,23 @@ module Spree
14
14
  setorderno country, 0
15
15
  end
16
16
 
17
+ def setprice(country, price)
18
+ clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
19
+ if !clist || clist == []
20
+ zp = Spree::Zoned::Product.new
21
+ zp.spree_country_id = country
22
+ zp.spree_product_id = id
23
+ zp.orderno = 0
24
+ else
25
+ zp = clist[0]
26
+ end
27
+ zp.cprice = price
28
+ zp.save
29
+ end
30
+
17
31
  protected
18
32
 
19
- def setorderno(country, ono)
33
+ def setorderno(country, price)
20
34
  clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
21
35
  if clist == []
22
36
  zp = Spree::Zoned::Product.new
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ :name => "replace_index_rows",
3
+ :virtual_path => "spree/admin/products/index",
4
+ :replace_contents => "[data-hook='admin_products_index_rows']",
5
+ :partial => "spree/admin/zoned/index_rows",
6
+ )
@@ -0,0 +1,17 @@
1
+ <td>
2
+ <span class="handle"></span>&nbsp;
3
+ <%= product.sku rescue '' %>
4
+ </td>
5
+ <td><%= link_to product.try(:name), edit_admin_product_path(product) %></td>
6
+ <td><%= number_to_currency getCPrice(product) rescue '' %></td>
7
+ <td class="actions" data-hook="admin_products_index_row_actions">
8
+ <%= link_to_edit product, :class => 'edit' unless product.deleted? %>
9
+ &nbsp;
10
+ <%= link_to_clone product, :class => 'clone' %>
11
+ &nbsp;
12
+ <%= link_to_delete product unless product.deleted? %>
13
+ <span class='delfromcountry'>
14
+ &nbsp;
15
+ <%= link_to_deletefc product unless product.deleted? %>
16
+ </span>
17
+ </td>
@@ -1,12 +1,13 @@
1
1
  <%= f.field_container :price do %>
2
2
  <%= f.label :price, t(:master_price) %> <span class="required">*</span>
3
3
  <br />(<%= t('country') + ": " -%>
4
- <% country = session[:zoned] && session[:zoned][:prd_country].to_i %>
4
+ <% country = session[:zoned] && session[:zoned][:prd_country] %>
5
+ <% country = country ? country.to_i : 0 %>
5
6
  <% c = Rails.application.config.commonCountriesForSelect.select {|e| e[1]==country} %>
6
7
  <%= c.length == 1 ? c[0][0] : t(:nocountrysel) -%>
7
8
  )<br />
8
9
  <%= f.text_field :price, :value => number_with_precision(
9
- @product.price, precision: 2)%>
10
+ getCPrice(@product), precision: 2)%>
10
11
  <%= f.error_message_on :price %>
11
12
  <% end %>
12
13
 
@@ -0,0 +1,5 @@
1
+ class AddCpriceToSpreeZonedProducts < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_zoned_products, :cprice, :decimal, :null => true, :default => nil, :precision => 8, :scale => 2
4
+ end
5
+ end
data/spree_zoned.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_zoned'
5
- s.version = '0.5.18'
5
+ s.version = '0.5.19'
6
6
  s.summary = 'A Spree extension to make your store zoned'
7
7
  s.description = "Everything you need for a zoned Spree store: zoned pricing, zoned products, zoned product ordering, zoned locales, ...\nProbalbly essential to you if you operate outside of the US."
8
8
  s.required_ruby_version = '>= 1.9.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_zoned
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.18
4
+ version: 0.5.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-30 00:00:00.000000000 Z
12
+ date: 2012-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
@@ -135,15 +135,15 @@ files:
135
135
  - app/controllers/spree/products_controller_decorator.rb
136
136
  - app/controllers/spree/zoned_controller.rb
137
137
  - app/helpers/spree/admin/navigation_helper_decorator.rb
138
+ - app/helpers/spree/admin/products_helper_decorator.rb
138
139
  - app/helpers/spree/base_helper_decorator.rb
139
140
  - app/models/spree/product_decorator.rb
140
141
  - app/models/spree/zoned/product.rb
141
142
  - app/overrides/add_country_selectbox.rb
142
- - app/overrides/add_delfc.rb
143
143
  - app/overrides/add_prd_country.rb
144
- - app/overrides/add_prd_handles.rb
145
144
  - app/overrides/replace_admin_product_right.rb
146
- - app/views/spree/admin/zoned/_delfc.html.erb
145
+ - app/overrides/replace_index_rows.rb
146
+ - app/views/spree/admin/zoned/_index_rows.html.erb
147
147
  - app/views/spree/admin/zoned/_prd_country.html.erb
148
148
  - app/views/spree/admin/zoned/_productright.html.erb
149
149
  - app/views/spree/admin/zoned/setcountry.js.erb
@@ -154,6 +154,7 @@ files:
154
154
  - config/locales/en.yml
155
155
  - config/routes.rb
156
156
  - db/migrate/20120611133806_create_spree_zoned_products.rb
157
+ - db/migrate/20120630201058_add_cprice_to_spree_zoned_products.rb
157
158
  - lib/generators/spree_zoned/install/install_generator.rb
158
159
  - lib/spree/zoned/search/base.rb
159
160
  - lib/spree_zoned.rb
@@ -1,6 +0,0 @@
1
- Deface::Override.new(
2
- :name => "add_delfc",
3
- :virtual_path => "spree/admin/products/index",
4
- :insert_bottom => "[data-hook='admin_products_index_row_actions']",
5
- :partial => "spree/admin/zoned/delfc",
6
- )
@@ -1,6 +0,0 @@
1
- Deface::Override.new(
2
- :name => "add_prd_handles",
3
- :virtual_path => "spree/admin/products/index",
4
- :insert_top => "[data-hook='admin_products_index_rows'] > td:first-child",
5
- :text => '<span class="handle"></span>&nbsp;',
6
- )
@@ -1,4 +0,0 @@
1
- <span class='delfromcountry'>
2
- &nbsp;
3
- <%= link_to_deletefc product unless product.deleted? %>
4
- </span>