spree_restriction 1.2.3 → 1.2.4
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.
- data/app/lib/base_decorator.rb +38 -0
- data/config/locales/fr.yml +3 -0
- data/spree_restriction.gemspec +1 -1
- metadata +3 -2
data/app/lib/base_decorator.rb
CHANGED
@@ -21,3 +21,41 @@ Spree::Core::Search::Base.class_eval do
|
|
21
21
|
@properties[:user_id] = params[:user_id]
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
if (defined? Spree::Core::Search::ProductGroupBase)
|
26
|
+
Spree::Core::Search::ProductGroupBase.class_eval do
|
27
|
+
def get_base_scope
|
28
|
+
roles = @properties[:user_id] ? Spree::User.find(@properties[:user_id]).spree_roles.dup : []
|
29
|
+
base_scope = @cached_product_group ? @cached_product_group.products.active : Spree::Product.active
|
30
|
+
base_scope = base_scope.by_roles(roles)
|
31
|
+
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
|
32
|
+
base_scope = get_products_conditions_for(base_scope, keywords) unless keywords.blank?
|
33
|
+
|
34
|
+
base_scope = base_scope.on_hand unless Spree::Config[:show_zero_stock_products]
|
35
|
+
base_scope = base_scope.group_by_products_id if @product_group.product_scopes.size > 1
|
36
|
+
base_scope
|
37
|
+
end
|
38
|
+
|
39
|
+
def prepare(params)
|
40
|
+
@properties[:taxon] = params[:taxon].blank? ? nil : Spree::Taxon.find(params[:taxon])
|
41
|
+
@properties[:keywords] = params[:keywords]
|
42
|
+
|
43
|
+
per_page = params[:per_page].to_i
|
44
|
+
@properties[:per_page] = per_page > 0 ? per_page : Spree::Config[:products_per_page]
|
45
|
+
@properties[:page] = (params[:page].to_i <= 0) ? 1 : params[:page].to_i
|
46
|
+
|
47
|
+
if !params[:order_by_price].blank?
|
48
|
+
@product_group = Spree::ProductGroup.new.from_route([params[:order_by_price] + '_by_master_price'])
|
49
|
+
elsif params[:product_group_name]
|
50
|
+
@cached_product_group = Spree::ProductGroup.find_by_permalink(params[:product_group_name])
|
51
|
+
@product_group = Spree::ProductGroup.new
|
52
|
+
elsif params[:product_group_query]
|
53
|
+
@product_group = Spree::ProductGroup.new.from_route(params[:product_group_query].split('/'))
|
54
|
+
else
|
55
|
+
@product_group = Spree::ProductGroup.new
|
56
|
+
end
|
57
|
+
@product_group = @product_group.from_search(params[:search]) if params[:search]
|
58
|
+
@properties[:user_id] = params[:user_id]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spree_restriction.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_restriction'
|
5
|
-
s.version = '1.2.
|
5
|
+
s.version = '1.2.4'
|
6
6
|
s.summary = 'Spree extension for adding visibility restriction by roles to products.'
|
7
7
|
s.description = 'Spree extension for adding visibility restriction by roles to products.'
|
8
8
|
s.required_ruby_version = '>= 1.8.7'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_restriction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
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-10-
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- app/models/role_decorator.rb
|
52
52
|
- app/overrides/add_restriction_to_admin.rb
|
53
53
|
- config/locales/en.yml
|
54
|
+
- config/locales/fr.yml
|
54
55
|
- config/routes.rb
|
55
56
|
- db/migrate/20120926201604_add_restrictions.rb
|
56
57
|
- lib/generators/spree_restriction/install/install_generator.rb
|