spree_marketplace 3.1.0 → 3.1.1
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/spree/suppliers_controller.rb +6 -2
- data/app/models/spree/supplier_ability.rb +72 -28
- data/app/models/spree/supplier_decorator.rb +25 -2
- data/app/views/spree/suppliers/new.html.erb +1 -1
- data/spree_marketplace.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf046fb139b2a599dab54c1650fb392e4691a24f
|
4
|
+
data.tar.gz: 25642a8389b0797353ee76a647f28e54e896255d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a5f656116577d33657330ea322f74b1744f71a886901eacc38c72d41702b723a65a21ccc2a39909bcc72d46411c8792f923441ce7ec0bebcdbf6919a0bf1b1
|
7
|
+
data.tar.gz: 90cea58e2cb37d17bfcf1bce1117287aec4e34fc7ffd583f243a1622ddffa36091bc0d6ad8b0784667430bcc187bdc48919e624f94c26447f8bb501db5d66ca3
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Installation
|
|
30
30
|
Add spree_marketplace to your Gemfile:
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
gem 'spree_marketplace', github: '
|
33
|
+
gem 'spree_marketplace', github: '0bserver07/spree_marketplace'
|
34
34
|
```
|
35
35
|
|
36
36
|
Bundle your dependencies and run the installation generator:
|
@@ -84,4 +84,4 @@ TODO
|
|
84
84
|
- Refactor to not rely on stripe & be interchangeable.
|
85
85
|
- suppliers should be able to manage option types and values (unsure about whether to scope to supplier or not, but thats probably best solution for everyone)
|
86
86
|
|
87
|
-
|
87
|
+
|
@@ -39,7 +39,7 @@ class Spree::SuppliersController < Spree::StoreController
|
|
39
39
|
|
40
40
|
if @supplier.save
|
41
41
|
flash[:success] = Spree.t('supplier_registration.create.success')
|
42
|
-
redirect_to
|
42
|
+
redirect_to '/'
|
43
43
|
else
|
44
44
|
render :new
|
45
45
|
end
|
@@ -61,7 +61,11 @@ class Spree::SuppliersController < Spree::StoreController
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def supplier_params
|
64
|
-
params.require(:supplier).permit(:first_name, :name, :last_name, :tax_id, :profile_picture)
|
64
|
+
params.require(:supplier).permit(:first_name, :name, :last_name, :tax_id, :profile_picture,:approved,:agree_tos,:agree_not_dropshiped,:agree_tos_violate)
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
@@ -2,10 +2,77 @@ module Spree
|
|
2
2
|
class SupplierAbility
|
3
3
|
include CanCan::Ability
|
4
4
|
|
5
|
+
require "byebug"
|
5
6
|
def initialize(user)
|
6
7
|
user ||= Spree.user_class.new
|
7
8
|
|
8
|
-
if user.supplier
|
9
|
+
if user.supplier and user.supplier.approved == true
|
10
|
+
|
11
|
+
# conditions = {supplier_id: user.supplier_id}
|
12
|
+
|
13
|
+
# can :products, :review_admissions
|
14
|
+
|
15
|
+
# can :read, :all
|
16
|
+
# can [:admin, :manage,:index], Spree::Review do |product|
|
17
|
+
# product.supplier_ids.include?(user.supplier_id)
|
18
|
+
# end
|
19
|
+
|
20
|
+
# can [:admin, :manage, :index], Spree::Review do |product|
|
21
|
+
# product.supplier_ids.include?(user.supplier_id)
|
22
|
+
# end
|
23
|
+
# can [:admin,:manage], Spree::Review
|
24
|
+
|
25
|
+
can [:admin,:manage,:index], Spree::Supplier, id: user.supplier_id
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# can [:create], Spree::AdmissionReview
|
30
|
+
# can [:admin, :manage], Spree::AdmissionReview, supplier: { supplier_id: user.supplier_id }
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
can [:admin, :manage, :stock,:admission], Spree::Product do |product|
|
36
|
+
product.supplier_ids.include?(user.supplier_id)
|
37
|
+
end
|
38
|
+
can [:admin, :create, :index,:admission], Spree::Product
|
39
|
+
|
40
|
+
can [:create], Spree::Prototype
|
41
|
+
can [:admin, :manage], Spree::Prototype, id: user.supplier.prototypes.pluck(:id)
|
42
|
+
|
43
|
+
# Action for listing?
|
44
|
+
can [:create], Spree::Property
|
45
|
+
can [:admin, :index], Spree::Property, id: user.supplier.properties.pluck(:id)
|
46
|
+
|
47
|
+
can [:create], Spree::OptionType
|
48
|
+
can [:admin, :manage], Spree::OptionType, id: user.supplier.option_types.pluck(:id)
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
can [:admin, :index, :read], Spree::ShippingCategory
|
53
|
+
|
54
|
+
can [:admin, :manage, :read, :ready, :ship], Spree::Shipment, order: { state: 'complete' }, stock_location: { supplier_id: user.supplier_id }
|
55
|
+
|
56
|
+
|
57
|
+
can [:admin, :create, :update], :stock_items
|
58
|
+
can [:admin, :manage], Spree::StockItem, stock_location_id: user.supplier.stock_locations.pluck(:id)
|
59
|
+
can [:admin, :manage], Spree::StockLocation, supplier_id: user.supplier_id
|
60
|
+
can :create, Spree::StockLocation
|
61
|
+
can [:admin, :manage], Spree::StockMovement, stock_item: { stock_location_id: user.supplier.stock_locations.pluck(:id) }
|
62
|
+
can :create, Spree::StockMovement
|
63
|
+
|
64
|
+
|
65
|
+
can [:admin, :update], Spree::Supplier, id: user.supplier_id
|
66
|
+
|
67
|
+
# TODO: Want this to be inline like:
|
68
|
+
# can [:admin, :manage], Spree::Variant, supplier_ids: user.supplier_id
|
69
|
+
can [:admin, :create, :index], Spree::Variant
|
70
|
+
|
71
|
+
can [:admin, :manage], Spree::Variant do |variant|
|
72
|
+
variant.supplier_ids.include?(user.supplier_id)
|
73
|
+
end
|
74
|
+
|
75
|
+
|
9
76
|
if SpreeMarketplace::Engine.spree_digital_available?
|
10
77
|
# can [:admin, :manage], Spree::Digital, variant: { supplier_ids: user.supplier_id }
|
11
78
|
can [:admin, :manage], Spree::Digital do |digital|
|
@@ -29,32 +96,7 @@ module Spree
|
|
29
96
|
relation.relatable.supplier_ids.include?(user.supplier_id)
|
30
97
|
end
|
31
98
|
end
|
32
|
-
|
33
|
-
# can [:admin, :manage, :stock], Spree::Product, suppliers: { id: user.supplier_id }
|
34
|
-
can [:admin, :manage, :stock], Spree::Product do |product|
|
35
|
-
product.supplier_ids.include?(user.supplier_id)
|
36
|
-
end
|
37
|
-
can [:admin, :create, :index], Spree::Product
|
38
|
-
# can [:admin, :manage], Spree::ProductProperty, product: { supplier_ids: user.supplier_id }
|
39
|
-
can [:admin, :manage, :stock], Spree::ProductProperty do |property|
|
40
|
-
property.product.supplier_ids.include?(user.supplier_id)
|
41
|
-
end
|
42
|
-
can [:admin, :index, :read], Spree::Property
|
43
|
-
can [:admin, :read], Spree::Prototype
|
44
|
-
can [:admin, :manage, :read, :ready, :ship], Spree::Shipment, order: { state: 'complete' }, stock_location: { supplier_id: user.supplier_id }
|
45
|
-
can [:admin, :create, :update], :stock_items
|
46
|
-
can [:admin, :manage], Spree::StockItem, stock_location_id: user.supplier.stock_locations.pluck(:id)
|
47
|
-
can [:admin, :manage], Spree::StockLocation, supplier_id: user.supplier_id
|
48
|
-
can :create, Spree::StockLocation
|
49
|
-
can [:admin, :manage], Spree::StockMovement, stock_item: { stock_location_id: user.supplier.stock_locations.pluck(:id) }
|
50
|
-
can :create, Spree::StockMovement
|
51
|
-
can [:admin, :update], Spree::Supplier, id: user.supplier_id
|
52
|
-
# TODO: Want this to be inline like:
|
53
|
-
# can [:admin, :manage], Spree::Variant, supplier_ids: user.supplier_id
|
54
|
-
can [:admin, :create, :index], Spree::Variant
|
55
|
-
can [:admin, :manage], Spree::Variant do |variant|
|
56
|
-
variant.supplier_ids.include?(user.supplier_id)
|
57
|
-
end
|
99
|
+
|
58
100
|
end
|
59
101
|
|
60
102
|
if SpreeMarketplace::Config[:allow_signup]
|
@@ -70,7 +112,9 @@ module Spree
|
|
70
112
|
can :create, Ckeditor::Picture
|
71
113
|
can [:read, :index, :destroy], Ckeditor::Picture, supplier_id: user.supplier_id
|
72
114
|
end
|
73
|
-
end
|
74
115
|
|
116
|
+
|
117
|
+
|
118
|
+
end
|
75
119
|
end
|
76
120
|
end
|
@@ -1,10 +1,33 @@
|
|
1
1
|
Spree::Supplier.class_eval do
|
2
2
|
|
3
3
|
attr_accessor :first_name, :last_name, :merchant_type
|
4
|
-
|
4
|
+
|
5
|
+
#==========================================
|
6
|
+
# Associations
|
7
|
+
|
5
8
|
has_many :bank_accounts, class_name: 'Spree::SupplierBankAccount'
|
6
9
|
has_attached_file :profile_picture, dependent: :destroy, :styles => {:medium => "300x300>", :thumb => "100x100>"}, :path => ":rails_root/public/assets/profile_pictures/:style/:filename", :url => "/assets/profile_pictures/:style/:filename"
|
7
|
-
|
10
|
+
|
11
|
+
has_many :supplier_prototypes
|
12
|
+
has_many :prototypes, through: :supplier_prototypes
|
13
|
+
|
14
|
+
has_many :supplier_properties
|
15
|
+
has_many :properties, through: :supplier_properties
|
16
|
+
|
17
|
+
|
18
|
+
has_many :supplier_option_types
|
19
|
+
has_many :option_types, through: :supplier_option_types
|
20
|
+
|
21
|
+
|
22
|
+
# has_many :spree_supplier_prod_opt_types
|
23
|
+
# has_many :prototypes, through: :spree_supplier_prod_opt_types
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
#==========================================
|
29
|
+
|
30
|
+
validates_attachment :profile_picture, :content_type => { :content_type => /\Aimage\/.*\Z/ }, :size => { :in => 0..500.kilobytes }
|
8
31
|
|
9
32
|
validates :tax_id, length: { is: 9, allow_blank: true }
|
10
33
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<div data-hook="signup_inside_form">
|
17
17
|
<%= render :partial => 'spree/shared/supplier_form', :locals => { :form => form } %>
|
18
18
|
<p>
|
19
|
-
<%= form.submit Spree.t(:signup), :class => 'btn btn-lg btn-success btn-block' %>
|
19
|
+
<%= form.submit Spree.t(:signup), :class => 'btn btn-lg btn-success btn-block' %>
|
20
20
|
</p>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
data/spree_marketplace.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_marketplace
|
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
|
- Y F
|
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: stripe
|