spree_drop_ship 3.1.0.1 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/products_controller_decorator.rb +10 -0
- data/app/controllers/spree/base_controller_decorator.rb +8 -8
- data/app/models/spree/product_decorator.rb +4 -2
- data/app/models/spree/supplier.rb +2 -0
- data/app/models/spree/variant_decorator.rb +13 -12
- data/app/views/spree/admin/suppliers/_form.html.erb +6 -0
- data/app/views/spree/admin/suppliers/index.html.erb +2 -0
- data/spree_drop_ship.gemspec +1 -1
- metadata +2 -3
- data/app/models/spree/supplier_ability.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfccc41f7846d3ac4e10410fa119be1fce2fa1d
|
4
|
+
data.tar.gz: 13035375388077460f4eeb9fecef8b479d07d637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f56e29dcd7cc1a5cb1603491162dad0f973546f603eefb22832a8126b5abf9200436e1e681f2a7ed9b025741feb94f0d5dbfd97bab2c9b26b7ea7a6741d069
|
7
|
+
data.tar.gz: 1f3597e4921b535b34621a1c0883736fe14a88db027277b865dd2ce6cbf3850fb6f03635ffb452e5f26d975b876551aa54315d2e4a9ee68adc5beaaaadd9533a
|
@@ -2,6 +2,16 @@ Spree::Admin::ProductsController.class_eval do
|
|
2
2
|
|
3
3
|
before_filter :get_suppliers, only: [:edit, :update]
|
4
4
|
before_filter :supplier_collection, only: [:index]
|
5
|
+
create.after :create_after
|
6
|
+
|
7
|
+
def create_after
|
8
|
+
if spree_current_user.supplier?
|
9
|
+
@product.add_supplier!(spree_current_user.supplier)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
5
15
|
|
6
16
|
private
|
7
17
|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
Spree::BaseController.class_eval do
|
2
2
|
|
3
3
|
prepend_before_filter :redirect_supplier
|
4
|
-
|
4
|
+
before_action :authorize_supplier
|
5
5
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def authorize_supplier
|
9
|
-
if respond_to?(:model_class, true) && model_class
|
10
|
-
|
11
|
-
else
|
12
|
-
|
13
|
-
end
|
14
|
-
authorize! :supplier, record
|
15
|
-
authorize! :action, record
|
9
|
+
# if respond_to?(:model_class, true) && model_class
|
10
|
+
# record = model_class
|
11
|
+
# else
|
12
|
+
# record = controller_name.to_sym
|
13
|
+
# end
|
14
|
+
# authorize! :supplier, record
|
15
|
+
# authorize! :action, record
|
16
16
|
end
|
17
17
|
|
18
18
|
def redirect_supplier
|
@@ -1,7 +1,9 @@
|
|
1
1
|
Spree::Product.class_eval do
|
2
2
|
|
3
|
+
before_create :add_supplier_to_product
|
3
4
|
has_many :suppliers, through: :master
|
4
5
|
|
6
|
+
|
5
7
|
def add_supplier!(supplier_or_id)
|
6
8
|
supplier = supplier_or_id.is_a?(Spree::Supplier) ? supplier_or_id : Spree::Supplier.find(supplier_or_id)
|
7
9
|
populate_for_supplier! supplier if supplier
|
@@ -18,13 +20,13 @@ Spree::Product.class_eval do
|
|
18
20
|
suppliers.present?
|
19
21
|
end
|
20
22
|
|
21
|
-
private
|
23
|
+
# private
|
22
24
|
|
23
25
|
def populate_for_supplier!(supplier)
|
24
26
|
variants_including_master.each do |variant|
|
25
27
|
unless variant.suppliers.pluck(:id).include?(supplier.id)
|
26
28
|
variant.suppliers << supplier
|
27
|
-
supplier.stock_locations.each { |location| location.propagate_variant(variant) }
|
29
|
+
# supplier.stock_locations.each { |location| location.propagate_variant(variant) }
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -4,21 +4,22 @@ module Spree
|
|
4
4
|
has_many :suppliers, through: :supplier_variants
|
5
5
|
has_many :supplier_variants
|
6
6
|
|
7
|
-
before_create :populate_for_suppliers
|
7
|
+
# before_create :populate_for_suppliers
|
8
8
|
|
9
|
-
private
|
10
9
|
|
11
|
-
|
12
|
-
StockLocation.all.each do |stock_location|
|
13
|
-
if stock_location.supplier_id.blank? || self.suppliers.pluck(:id).include?(stock_location.supplier_id)
|
14
|
-
stock_location.propagate_variant(self) if stock_location.propagate_all_variants?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
10
|
+
# private
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
# durably_decorate :create_stock_items, mode: 'soft', sha: '98704433ac5c66ba46e02699f3cf03d13d4f1281' do
|
13
|
+
# StockLocation.all.each do |stock_location|
|
14
|
+
# if stock_location.supplier_id.blank? || self.suppliers.pluck(:id).include?(stock_location.supplier_id)
|
15
|
+
# stock_location.propagate_variant(self) if stock_location.propagate_all_variants?
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
|
20
|
+
# def populate_for_suppliers
|
21
|
+
# self.suppliers = self.product.suppliers
|
22
|
+
# end
|
22
23
|
|
23
24
|
end
|
24
25
|
end
|
@@ -30,6 +30,12 @@
|
|
30
30
|
<%= form.text_field :tax_id, :class => 'form-control' %>
|
31
31
|
<% end %>
|
32
32
|
<% if spree_current_user.admin? %>
|
33
|
+
<div class="checkbox">
|
34
|
+
<%= label_tag :approved do %>
|
35
|
+
<%= form.check_box :approved %>
|
36
|
+
<%= Spree::Supplier.human_attribute_name(:approved) %>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
33
39
|
<%= form.field_container :commission_flat_rate, class: ['form-group'] do %>
|
34
40
|
<%= form.label :commission_flat_rate, Spree::Supplier.human_attribute_name(:commission_flat_rate) %>:<br />
|
35
41
|
<%= form.text_field :commission_flat_rate, :class => 'form-control' %>
|
@@ -34,6 +34,7 @@
|
|
34
34
|
<thead>
|
35
35
|
<tr data-hook='admin_suppliers_index_headers'>
|
36
36
|
<th><%= sort_link @search, :name, Spree::Supplier.human_attribute_name(:name) %></th>
|
37
|
+
<th><%= sort_link @search, :approved, Spree::Supplier.human_attribute_name(:approved) %></th>
|
37
38
|
<th><%= sort_link @search, :email, Spree::Supplier.human_attribute_name(:email) %></th>
|
38
39
|
<th><%= Spree.t(:users) %></th>
|
39
40
|
<th><%= sort_link @search, :active, Spree::Supplier.human_attribute_name(:active) %></th>
|
@@ -46,6 +47,7 @@
|
|
46
47
|
<tr <%= "style='color: red;'" if supplier.deleted? %> id="<%= spree_dom_id supplier %>" data-hook="admin_suppliers_index_rows" class="<%= cycle('odd', 'even') %>">
|
47
48
|
<!--todo: Fix this link!-->
|
48
49
|
<td><%= link_to supplier.name, edit_object_url(supplier) %></td>
|
50
|
+
<td><%= supplier.approved %></td>
|
49
51
|
<td><%= mail_to supplier.email %></td>
|
50
52
|
<td><%= supplier.users.pluck(:email).join(', ') %></td>
|
51
53
|
<td><%= supplier.active %></td>
|
data/spree_drop_ship.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_drop_ship'
|
5
|
-
s.version = '3.1.
|
5
|
+
s.version = '3.1.1'
|
6
6
|
s.summary = 'Upgraded Spree Drop Shipping Extension'
|
7
7
|
s.description = 'Adds drop shipping functionality to Spree stores.'
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_drop_ship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yad Faeq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: durable_decorator
|
@@ -299,7 +299,6 @@ files:
|
|
299
299
|
- app/models/spree/stock/splitter/drop_ship.rb
|
300
300
|
- app/models/spree/stock_location_decorator.rb
|
301
301
|
- app/models/spree/supplier.rb
|
302
|
-
- app/models/spree/supplier_ability.rb
|
303
302
|
- app/models/spree/supplier_variant.rb
|
304
303
|
- app/models/spree/user_decorator.rb
|
305
304
|
- app/models/spree/variant_decorator.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class SupplierAbility
|
3
|
-
include CanCan::Ability
|
4
|
-
|
5
|
-
def initialize(user)
|
6
|
-
user ||= Spree.user_class.new
|
7
|
-
|
8
|
-
if user.supplier
|
9
|
-
# TODO: Want this to be inline like:
|
10
|
-
# can [:admin, :read, :stock], Spree::Product, suppliers: { id: user.supplier_id }
|
11
|
-
# can [:admin, :read, :stock], Spree::Product, supplier_ids: user.supplier_id
|
12
|
-
can [:admin, :read, :stock], Spree::Product do |product|
|
13
|
-
product.supplier_ids.include?(user.supplier_id)
|
14
|
-
end
|
15
|
-
can [:admin, :index, :manage, :create], Spree::Product
|
16
|
-
can [:admin, :manage, :read, :ready, :ship], Spree::Shipment, order: { state: 'complete' }, stock_location: { supplier_id: user.supplier_id }
|
17
|
-
can [:admin, :create, :update], :stock_items
|
18
|
-
can [:admin, :manage], Spree::StockItem, stock_location_id: user.supplier.stock_locations.pluck(:id)
|
19
|
-
can [:admin, :manage], Spree::StockLocation, supplier_id: user.supplier_id
|
20
|
-
can :create, Spree::StockLocation
|
21
|
-
can [:admin, :manage], Spree::StockMovement, stock_item: { stock_location_id: user.supplier.stock_locations.pluck(:id) }
|
22
|
-
can :create, Spree::StockMovement
|
23
|
-
can [:admin, :update], Spree::Supplier, id: user.supplier_id
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|