dscf-marketplace 0.2.1 → 0.2.3
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/app/controllers/dscf/marketplace/businesses_controller.rb +42 -6
- data/app/controllers/dscf/marketplace/listings_controller.rb +12 -0
- data/app/controllers/dscf/marketplace/orders_controller.rb +12 -0
- data/app/controllers/dscf/marketplace/quotations_controller.rb +12 -0
- data/app/controllers/dscf/marketplace/request_for_quotations_controller.rb +12 -0
- data/app/controllers/dscf/marketplace/supplier_products_controller.rb +12 -0
- data/app/serializers/dscf/marketplace/business_serializer.rb +1 -0
- data/app/serializers/dscf/marketplace/document_serializer.rb +7 -0
- data/app/services/dscf/marketplace/my_resource_service.rb +62 -0
- data/config/routes.rb +16 -0
- data/lib/dscf/marketplace/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6369ee5595ca023697c774365dee93c16a985614fc46057ee9effd1e2120a244
|
4
|
+
data.tar.gz: 696e16ed8bac9ba0b214979d69b3b133c3ea5a32374bc44dd7ef9db0253bac6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 218769eb0baba77cb42ec31c7519ea60ad1ed2483135446a98970cf18b928dc1ccc29a44dcdc941c144ac94cdf9098400628b9e521b4956f8bfe10c51913616b
|
7
|
+
data.tar.gz: aedbbb4601fab05aa6ce8e60470609286b71d5b3b6e7f9da201337073e12b5255c151fc16de074083c9511cbf10c6ff1d86d140cee6ae66bb95d1bf20df93d21
|
@@ -8,25 +8,61 @@ module Dscf
|
|
8
8
|
render_success("business.success.has_business_check", data: {has_business: has_business})
|
9
9
|
end
|
10
10
|
|
11
|
+
def create
|
12
|
+
business = @clazz.new(model_params.except(:business_license))
|
13
|
+
if business.save
|
14
|
+
# Add document upload after save
|
15
|
+
if params[:business][:business_license].present?
|
16
|
+
document = Dscf::Core::Document.new(
|
17
|
+
documentable: business,
|
18
|
+
document_type: :business_license
|
19
|
+
)
|
20
|
+
document.file.attach(params[:business][:business_license])
|
21
|
+
document.save!
|
22
|
+
end
|
23
|
+
|
24
|
+
business = @clazz.includes(eager_loaded_associations).find(business.id) if eager_loaded_associations.present?
|
25
|
+
includes = serializer_includes_for_action(:create)
|
26
|
+
options = {include: includes} if includes.present?
|
27
|
+
render_success(data: business, serializer_options: options, status: :created)
|
28
|
+
else
|
29
|
+
render_error(errors: business.errors.full_messages[0], status: :unprocessable_entity)
|
30
|
+
end
|
31
|
+
rescue => e
|
32
|
+
render_error(error: e.message)
|
33
|
+
end
|
34
|
+
|
35
|
+
def my_businesses
|
36
|
+
service = MyResourceService.new(current_user)
|
37
|
+
businesses = service.my_businesses(params)
|
38
|
+
|
39
|
+
options = {
|
40
|
+
include: default_serializer_includes[:index] || [],
|
41
|
+
meta: {resource_type: "my_businesses"}
|
42
|
+
}
|
43
|
+
|
44
|
+
render_success("businesses.success.index", data: businesses, serializer_options: options)
|
45
|
+
end
|
46
|
+
|
11
47
|
private
|
12
48
|
|
13
49
|
def model_params
|
14
50
|
params.require(:business).permit(
|
15
51
|
:name, :description, :contact_email, :contact_phone, :tin_number,
|
16
|
-
:business_type_id, :user_id
|
52
|
+
:business_type_id, :user_id, business_license: :file
|
17
53
|
)
|
18
54
|
end
|
19
55
|
|
20
56
|
def eager_loaded_associations
|
21
|
-
[ :business_type, :user ]
|
57
|
+
[ :business_type, :user, :documents ]
|
22
58
|
end
|
23
59
|
|
24
60
|
def default_serializer_includes
|
25
61
|
{
|
26
|
-
index: [ :business_type, :user ],
|
27
|
-
show: [ :business_type, :user ],
|
28
|
-
create: [ :business_type, :user ],
|
29
|
-
update: [ :business_type, :user ]
|
62
|
+
index: [ :business_type, :user, :documents ],
|
63
|
+
show: [ :business_type, :user, :documents ],
|
64
|
+
create: [ :business_type, :user, :documents ],
|
65
|
+
update: [ :business_type, :user, :documents ]
|
30
66
|
}
|
31
67
|
end
|
32
68
|
end
|
@@ -30,6 +30,18 @@ module Dscf
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def my_listings
|
34
|
+
service = MyResourceService.new(current_user)
|
35
|
+
listings = service.my_listings(params)
|
36
|
+
|
37
|
+
options = {
|
38
|
+
include: default_serializer_includes[:index] || [],
|
39
|
+
meta: {resource_type: "my_listings"}
|
40
|
+
}
|
41
|
+
|
42
|
+
render_success("listings.success.index", data: listings, serializer_options: options)
|
43
|
+
end
|
44
|
+
|
33
45
|
private
|
34
46
|
|
35
47
|
def model_params
|
@@ -32,6 +32,18 @@ module Dscf
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def my_orders
|
36
|
+
service = MyResourceService.new(current_user)
|
37
|
+
orders = service.my_orders(params)
|
38
|
+
|
39
|
+
options = {
|
40
|
+
include: default_serializer_includes[:index] || [],
|
41
|
+
meta: {resource_type: "my_orders"}
|
42
|
+
}
|
43
|
+
|
44
|
+
render_success("orders.success.index", data: orders, serializer_options: options)
|
45
|
+
end
|
46
|
+
|
35
47
|
private
|
36
48
|
|
37
49
|
def model_params
|
@@ -30,6 +30,18 @@ module Dscf
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def my_quotes
|
34
|
+
service = MyResourceService.new(current_user)
|
35
|
+
quotes = service.my_quotes(params)
|
36
|
+
|
37
|
+
options = {
|
38
|
+
include: default_serializer_includes[:index] || [],
|
39
|
+
meta: {resource_type: "my_quotes"}
|
40
|
+
}
|
41
|
+
|
42
|
+
render_success("quotations.success.index", data: quotes, serializer_options: options)
|
43
|
+
end
|
44
|
+
|
33
45
|
private
|
34
46
|
|
35
47
|
def model_params
|
@@ -21,6 +21,18 @@ module Dscf
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def my_rfqs
|
25
|
+
service = MyResourceService.new(current_user)
|
26
|
+
rfqs = service.my_rfqs(params)
|
27
|
+
|
28
|
+
options = {
|
29
|
+
include: default_serializer_includes[:index] || [],
|
30
|
+
meta: {resource_type: "my_rfqs"}
|
31
|
+
}
|
32
|
+
|
33
|
+
render_success("request_for_quotations.success.index", data: rfqs, serializer_options: options)
|
34
|
+
end
|
35
|
+
|
24
36
|
private
|
25
37
|
|
26
38
|
def model_params
|
@@ -3,6 +3,18 @@ module Dscf
|
|
3
3
|
class SupplierProductsController < ApplicationController
|
4
4
|
include Dscf::Core::Common
|
5
5
|
|
6
|
+
def my_products
|
7
|
+
service = MyResourceService.new(current_user)
|
8
|
+
products = service.my_products(params)
|
9
|
+
|
10
|
+
options = {
|
11
|
+
include: default_serializer_includes[:index] || [],
|
12
|
+
meta: {resource_type: "my_products"}
|
13
|
+
}
|
14
|
+
|
15
|
+
render_success("supplier_products.success.index", data: products, serializer_options: options)
|
16
|
+
end
|
17
|
+
|
6
18
|
private
|
7
19
|
|
8
20
|
def model_params
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class MyResourceService
|
4
|
+
def initialize(current_user)
|
5
|
+
@current_user = current_user
|
6
|
+
end
|
7
|
+
|
8
|
+
def my_orders(params = {})
|
9
|
+
orders = Dscf::Marketplace::Order.where(user: @current_user)
|
10
|
+
.includes(:quotation, :listing, :user, :delivery_order, :order_items)
|
11
|
+
|
12
|
+
apply_filters(orders, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def my_rfqs(params = {})
|
16
|
+
rfqs = Dscf::Marketplace::RequestForQuotation.where(user: @current_user)
|
17
|
+
.includes(:user, :selected_quotation, :rfq_items, :quotations)
|
18
|
+
|
19
|
+
apply_filters(rfqs, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def my_quotes(params = {})
|
23
|
+
quotes = Dscf::Marketplace::Quotation.joins(:request_for_quotation)
|
24
|
+
.where(dscf_marketplace_request_for_quotations: {user_id: @current_user.id})
|
25
|
+
.includes(:request_for_quotation, :business, :quotation_items, :order)
|
26
|
+
|
27
|
+
apply_filters(quotes, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def my_businesses(params = {})
|
31
|
+
@current_user.businesses.includes(:business_type, :user, :documents)
|
32
|
+
end
|
33
|
+
|
34
|
+
def my_listings(params = {})
|
35
|
+
listings = Dscf::Marketplace::Listing.joins(:business)
|
36
|
+
.where(dscf_core_businesses: {user_id: @current_user.id})
|
37
|
+
.includes(:business, :supplier_product, :order_items)
|
38
|
+
|
39
|
+
apply_filters(listings, params)
|
40
|
+
end
|
41
|
+
|
42
|
+
def my_products(params = {})
|
43
|
+
products = Dscf::Marketplace::SupplierProduct.joins(:business)
|
44
|
+
.where(dscf_core_businesses: {user_id: @current_user.id})
|
45
|
+
.includes(:business, :product, :listings)
|
46
|
+
|
47
|
+
apply_filters(products, params)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def apply_filters(query, params)
|
53
|
+
# Apply Ransack filtering
|
54
|
+
if params[:q].present?
|
55
|
+
query = query.ransack(params[:q]).result
|
56
|
+
end
|
57
|
+
|
58
|
+
query
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/config/routes.rb
CHANGED
@@ -19,12 +19,16 @@ Dscf::Marketplace::Engine.routes.draw do
|
|
19
19
|
resources :businesses do
|
20
20
|
collection do
|
21
21
|
get "has_business"
|
22
|
+
get "my_businesses"
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
# Trading Models
|
26
27
|
resources :supplier_products do
|
27
28
|
resources :listings, only: [ :index ]
|
29
|
+
collection do
|
30
|
+
get "my_products"
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
resources :listings do
|
@@ -33,6 +37,9 @@ Dscf::Marketplace::Engine.routes.draw do
|
|
33
37
|
post "pause"
|
34
38
|
post "sold_out"
|
35
39
|
end
|
40
|
+
collection do
|
41
|
+
get "my_listings"
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
# RFQ System
|
@@ -43,6 +50,9 @@ Dscf::Marketplace::Engine.routes.draw do
|
|
43
50
|
post "send_rfq"
|
44
51
|
post "close"
|
45
52
|
end
|
53
|
+
collection do
|
54
|
+
get "my_rfqs"
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
58
|
resources :rfq_items, only: [ :index, :show, :update, :create, :destroy ]
|
@@ -54,6 +64,9 @@ Dscf::Marketplace::Engine.routes.draw do
|
|
54
64
|
post "reject"
|
55
65
|
post "send_quotation"
|
56
66
|
end
|
67
|
+
collection do
|
68
|
+
get "my_quotes"
|
69
|
+
end
|
57
70
|
end
|
58
71
|
|
59
72
|
resources :quotation_items, only: [ :index, :show, :update, :create, :destroy ]
|
@@ -66,6 +79,9 @@ Dscf::Marketplace::Engine.routes.draw do
|
|
66
79
|
post "cancel"
|
67
80
|
post "complete"
|
68
81
|
end
|
82
|
+
collection do
|
83
|
+
get "my_orders"
|
84
|
+
end
|
69
85
|
end
|
70
86
|
|
71
87
|
resources :order_items, only: [ :index, :show, :update, :create, :destroy ]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dscf-marketplace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asrat
|
@@ -456,6 +456,7 @@ files:
|
|
456
456
|
- app/serializers/dscf/marketplace/delivery_order_item_serializer.rb
|
457
457
|
- app/serializers/dscf/marketplace/delivery_order_serializer.rb
|
458
458
|
- app/serializers/dscf/marketplace/delivery_vehicle_serializer.rb
|
459
|
+
- app/serializers/dscf/marketplace/document_serializer.rb
|
459
460
|
- app/serializers/dscf/marketplace/listing_serializer.rb
|
460
461
|
- app/serializers/dscf/marketplace/order_item_serializer.rb
|
461
462
|
- app/serializers/dscf/marketplace/order_serializer.rb
|
@@ -467,6 +468,7 @@ files:
|
|
467
468
|
- app/serializers/dscf/marketplace/supplier_product_serializer.rb
|
468
469
|
- app/serializers/dscf/marketplace/unit_conversion_serializer.rb
|
469
470
|
- app/serializers/dscf/marketplace/unit_serializer.rb
|
471
|
+
- app/services/dscf/marketplace/my_resource_service.rb
|
470
472
|
- config/locales/en.yml
|
471
473
|
- config/routes.rb
|
472
474
|
- db/migrate/20250827172043_create_dscf_marketplace_categories.rb
|