spree_zoned 0.5.24 → 0.5.25
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/spree/admin/products_controller_decorator.rb +0 -6
- data/app/controllers/spree/base_controller_decorator.rb +16 -0
- data/app/controllers/spree/zoned_controller.rb +18 -1
- data/app/helpers/spree/base_helper_decorator.rb +6 -0
- data/app/views/spree/zoned/_countryselect.html.erb +16 -1
- data/app/views/spree/zoned/setlanguage.js.erb +1 -0
- data/config/initializers/zoned_init.rb +12 -10
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/routes.rb +1 -0
- data/spree_zoned.gemspec +1 -1
- metadata +4 -2
@@ -15,16 +15,11 @@ Spree::Admin::ProductsController.class_eval do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def update
|
18
|
-
puts "Here spree/admin/products_controller/update"
|
19
|
-
puts "BEFORE: @product.price: #{@product.price}"
|
20
|
-
puts "params[:product][:price]: #{params[:product][:price]}"
|
21
18
|
params[:product][:price] = Delocalize::LocalizedNumericParser.parse(params[:product][:price])
|
22
|
-
puts "params[:product][:price] after parse: #{params[:product][:price]}"
|
23
19
|
# delete cprice to prevent mass assignemnt error in ActiveModel
|
24
20
|
# cprice has already been handled in before_filter "delocSetrPrice"
|
25
21
|
params[:product].delete :cprice
|
26
22
|
@product.update_attributes(params[:product])
|
27
|
-
puts "AFTER: @product.price: #{@product.price}"
|
28
23
|
redirect_to :action => 'edit'
|
29
24
|
end
|
30
25
|
|
@@ -108,7 +103,6 @@ protected
|
|
108
103
|
def delocSetPrice
|
109
104
|
country = session[:zoned] && session[:zoned][:prd_country]
|
110
105
|
if country && country.to_i != 0 && params[:product] && params[:product][:cprice]
|
111
|
-
puts "Here delocSetPrice before setprice: params[:product][:cprice]: #{params[:product][:cprice]}"
|
112
106
|
@product.setprice(country.to_i, BigDecimal.new(Delocalize::LocalizedNumericParser.parse(params[:product][:cprice])))
|
113
107
|
end
|
114
108
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Spree::BaseController.class_eval do
|
2
|
+
before_filter :set_locale #, :if => proc { !session[:locale] }
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def set_locale
|
7
|
+
I18n.locale = extract_locale || I18n.default_locale
|
8
|
+
end
|
9
|
+
|
10
|
+
def extract_locale
|
11
|
+
parsed_locale = (session[:zoned] && session[:zoned][:current_language]) || I18n.default_locale
|
12
|
+
#I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
|
13
|
+
parsed_locale ? parsed_locale.to_sym : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,12 +1,29 @@
|
|
1
1
|
module Spree
|
2
2
|
class ZonedController < BaseController
|
3
|
+
|
4
|
+
def availLangs(country)
|
5
|
+
Rails.configuration.availableLanguages[country] || ["English", "en"]
|
6
|
+
end
|
7
|
+
|
3
8
|
def setcountry
|
4
9
|
respond_to do |format|
|
5
10
|
format.js do
|
6
11
|
session[:zoned] ||= {}
|
7
|
-
session[:zoned][:current_country] = params[:id]
|
12
|
+
c = session[:zoned][:current_country] = params[:id]
|
13
|
+
c = c.to_i
|
14
|
+
session[:zoned][:current_language] = (availLangs(c) && availLangs(c)[0][1]) || "en"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def setlanguage
|
20
|
+
respond_to do |format|
|
21
|
+
format.js do
|
22
|
+
session[:zoned] ||= {}
|
23
|
+
session[:zoned][:current_language] = params[:lgid]
|
8
24
|
end
|
9
25
|
end
|
10
26
|
end
|
27
|
+
|
11
28
|
end
|
12
29
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
<div id="zoned-countryselect" class="columns omega ten">
|
2
|
+
<% c = ((session[:zoned] && session[:zoned][:current_country]) || -214) %>
|
2
3
|
<%= label_tag t('country') + ": " %>
|
3
4
|
<%= select_tag 'id',
|
4
5
|
options_for_select( # common countries have negative id
|
5
6
|
Rails.application.config.commonCountriesForSelect +
|
6
7
|
[["-----------------", 0]] +
|
7
8
|
countrylist.map { |country| [country.name, country.id] },
|
8
|
-
|
9
|
+
c,
|
9
10
|
),
|
10
11
|
:data => {
|
11
12
|
:remote => true,
|
@@ -15,4 +16,18 @@
|
|
15
16
|
),
|
16
17
|
}
|
17
18
|
%>
|
19
|
+
<%= label_tag t('language') + ": " %>
|
20
|
+
<%= select_tag 'lgid',
|
21
|
+
options_for_select( # common countries have negative id
|
22
|
+
hlpAvailLangs(c.to_i),
|
23
|
+
(session[:zoned] && session[:zoned][:current_language]) || "en", # English
|
24
|
+
),
|
25
|
+
:data => {
|
26
|
+
:remote => true,
|
27
|
+
:url => url_for(
|
28
|
+
:controller => "zoned",
|
29
|
+
:action => "setlanguage",
|
30
|
+
),
|
31
|
+
}
|
32
|
+
%>
|
18
33
|
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
location.reload();
|
@@ -18,24 +18,26 @@ ZONED_COMMON_COUNTRIES =
|
|
18
18
|
|
19
19
|
#
|
20
20
|
# ZONED_COMMOM_LOCALES specifies - for each contry contained in ZONED_COMMON_COUNTRIES - a list (array)
|
21
|
-
# of locales that are
|
21
|
+
# of locales that are possibile to select for that specific country.
|
22
22
|
# For all countries not included in ZONED_COMMON_COUNTRIES, the locale will automatically be set to :en.
|
23
23
|
# The first locale listed for each country is considered that countrie's default locale.
|
24
24
|
#
|
25
25
|
ZONED_COMMON_LOCALES =
|
26
|
-
|
27
|
-
[:en], # United States
|
28
|
-
[:de, :en], # Germany
|
29
|
-
[:de, :en], # Austria
|
30
|
-
[:de, :en], # Switzerland
|
31
|
-
[:nl, :en], # Netherlands
|
32
|
-
[:nl, :de, :en], # Belgium
|
33
|
-
[:de, :en], # Luxembourg
|
34
|
-
|
26
|
+
{
|
27
|
+
-214 => [:en], # United States
|
28
|
+
-74 => [:de, :en], # Germany
|
29
|
+
-13 => [:de, :en], # Austria
|
30
|
+
-195 => [:de, :en], # Switzerland
|
31
|
+
-142 => [:nl, :en], # Netherlands
|
32
|
+
-20 => [:nl, :de, :en], # Belgium
|
33
|
+
-117 => [:de, :en, :nl], # Luxembourg
|
34
|
+
}
|
35
35
|
|
36
36
|
Rails.configuration.commonCountriesForSelect = ZONED_COMMON_COUNTRIES.map do |id|
|
37
37
|
[ Spree::Country.find_by_id(id).name, -id ]
|
38
38
|
end
|
39
39
|
|
40
|
+
Rails.configuration.availableLanguages = Hash[ZONED_COMMON_LOCALES.map { |c, lgs| [c, lgs.map { |l| [((l==:en ? "English" : (l==:de ? "Deutsch" : "Nederlands"))) ,l]}]}]
|
41
|
+
|
40
42
|
Spree::Config.searcher_class = Spree::Zoned::Search::Base
|
41
43
|
Spree::Config.admin_products_per_page = 64
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
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.
|
5
|
+
s.version = '0.5.25'
|
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.
|
4
|
+
version: 0.5.25
|
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-
|
12
|
+
date: 2012-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- app/assets/stylesheets/store/spree_zoned.css
|
132
132
|
- app/controllers/spree/admin/products_controller_decorator.rb
|
133
133
|
- app/controllers/spree/admin/zoned_controller.rb
|
134
|
+
- app/controllers/spree/base_controller_decorator.rb
|
134
135
|
- app/controllers/spree/home_controller_decorator.rb
|
135
136
|
- app/controllers/spree/products_controller_decorator.rb
|
136
137
|
- app/controllers/spree/zoned_controller.rb
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- app/views/spree/shared/_products_list_item.html.erb
|
153
154
|
- app/views/spree/zoned/_countryselect.html.erb
|
154
155
|
- app/views/spree/zoned/setcountry.js.erb
|
156
|
+
- app/views/spree/zoned/setlanguage.js.erb
|
155
157
|
- config/initializers/zoned_init.rb
|
156
158
|
- config/locales/de.yml
|
157
159
|
- config/locales/en.yml
|