spree_cm_commissioner 2.3.0.pre.pre21 → 2.3.1.pre.pre1
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/Gemfile.lock +1 -1
- data/app/controllers/spree/admin/product_completion_steps_controller.rb +17 -1
- data/app/controllers/spree/admin/tenants_controller.rb +1 -1
- data/app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb +0 -1
- data/app/controllers/spree/api/v2/tenant/intercity_taxi/draft_orders_controller.rb +41 -0
- data/app/controllers/spree/api/v2/tenant/trip_places_controller.rb +48 -0
- data/app/controllers/spree/api/v2/tenant/trip_search_controller.rb +103 -0
- data/app/controllers/spree/api/v2/tenant/trips_controller.rb +32 -0
- data/app/interactors/spree_cm_commissioner/create_ticket.rb +2 -0
- data/app/interactors/spree_cm_commissioner/host_matcher.rb +1 -1
- data/app/interactors/spree_cm_commissioner/vendor_creation_telegram_alert_sender.rb +1 -1
- data/app/mailers/spree/order_mailer_decorator.rb +8 -9
- data/app/models/concerns/spree_cm_commissioner/service_recommendations.rb +2 -2
- data/app/models/concerns/spree_cm_commissioner/store_preference.rb +1 -0
- data/app/models/spree_cm_commissioner/product_completion_step.rb +4 -1
- data/app/models/spree_cm_commissioner/product_completion_step_banner.rb +12 -0
- data/app/models/spree_cm_commissioner/product_completion_steps/social_entry_url.rb +86 -19
- data/app/models/spree_cm_commissioner/tenant.rb +10 -1
- data/app/models/spree_cm_commissioner/vendor_place.rb +10 -1
- data/app/overrides/spree/admin/stores/_form/store_preferences.html.erb.deface +9 -0
- data/app/queries/spree_cm_commissioner/trip_query.rb +23 -17
- data/app/serializers/spree_cm_commissioner/v2/storefront/trip_vehicle_serializer.rb +1 -1
- data/app/services/spree_cm_commissioner/intercity_taxi_order/create.rb +8 -0
- data/app/services/spree_cm_commissioner/intercity_taxi_order/update.rb +35 -45
- data/app/views/shared/_asset_field.html.erb +13 -0
- data/app/views/spree/admin/product_completion_steps/_form.html.erb +28 -2
- data/app/views/spree/admin/product_completion_steps/_supported_fields.html.erb +33 -0
- data/app/views/spree/admin/tenants/_form.html.erb +1 -1
- data/config/initializers/spree_permitted_attributes.rb +1 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/km.yml +65 -61
- data/config/routes.rb +16 -0
- data/db/migrate/20251119093000_add_tenant_id_to_cm_vendor_places.rb +7 -0
- data/lib/spree_cm_commissioner/test_helper/factories/product_completion_step_banner_factory.rb +7 -0
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7791d1c6474375315937bc020c5bb5274abecbddc5e9b9f5df5a73e53576d626
|
|
4
|
+
data.tar.gz: 03c0f3ccc698d12697c135f4daaab5718b1a72117288de9270069397660d62a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cb82c98aac134ebedbdb29c1daf2cc22035ac4e5856c548b22015ffb9a574e6873e897407b8043d899164a9a1ffa941ec04fc25df2263e255e5fd1ad362531c
|
|
7
|
+
data.tar.gz: 4ff0e66a420d2e7f589f2c63d55ca18acc0065aa015033b3917a5dbf603440df4f8a56a32834a02135f5e216a2e5f7d82e8e78f5c6d1df571dc7b261ddb90a79
|
data/Gemfile.lock
CHANGED
|
@@ -4,6 +4,7 @@ module Spree
|
|
|
4
4
|
belongs_to 'spree/product', find_by: :slug
|
|
5
5
|
|
|
6
6
|
before_action :load_step_types, if: :member_action?
|
|
7
|
+
before_action :build_assets, only: %i[create update]
|
|
7
8
|
|
|
8
9
|
def load_step_types
|
|
9
10
|
@step_types = [
|
|
@@ -14,10 +15,13 @@ module Spree
|
|
|
14
15
|
|
|
15
16
|
# override
|
|
16
17
|
def permitted_resource_params
|
|
18
|
+
return @permitted_resource_params if defined?(@permitted_resource_params)
|
|
19
|
+
|
|
17
20
|
key = ActiveModel::Naming.param_key(@object)
|
|
18
21
|
permit_keys = params.require(key).keys
|
|
19
22
|
|
|
20
|
-
params.require(key).permit(permit_keys)
|
|
23
|
+
@permitted_resource_params = params.require(key).permit(permit_keys)
|
|
24
|
+
@permitted_resource_params
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
# @overrided
|
|
@@ -54,6 +58,18 @@ module Spree
|
|
|
54
58
|
def location_after_save
|
|
55
59
|
edit_object_url(@object)
|
|
56
60
|
end
|
|
61
|
+
|
|
62
|
+
def remove_banner
|
|
63
|
+
@object.banner&.destroy
|
|
64
|
+
flash[:success] = Spree.t(:successfully_removed)
|
|
65
|
+
redirect_to edit_object_url(@object)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def build_assets
|
|
71
|
+
@object.build_banner(attachment: permitted_resource_params.delete(:banner)) if permitted_resource_params[:banner].present?
|
|
72
|
+
end
|
|
57
73
|
end
|
|
58
74
|
end
|
|
59
75
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Tenant
|
|
5
|
+
module IntercityTaxi
|
|
6
|
+
class DraftOrdersController < BaseController
|
|
7
|
+
def create
|
|
8
|
+
order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
|
|
9
|
+
trip_id: params[:trip_id],
|
|
10
|
+
from_date: params[:from_date],
|
|
11
|
+
to_date: params[:to_date],
|
|
12
|
+
user_id: params[:user_id],
|
|
13
|
+
quantity: params[:quantity]
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
render_serialized_payload { serialize_resource(order) }
|
|
17
|
+
rescue StandardError => e
|
|
18
|
+
render_error_payload(e.message)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def update
|
|
22
|
+
order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
|
|
23
|
+
params: params
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
render_serialized_payload { serialize_resource(order) }
|
|
27
|
+
rescue StandardError => e
|
|
28
|
+
render_error_payload(e.message)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def resource_serializer
|
|
34
|
+
SpreeCmCommissioner::V2::Storefront::IntercityTaxiCartSerializer
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Tenant
|
|
5
|
+
class TripPlacesController < BaseController
|
|
6
|
+
def index
|
|
7
|
+
render_serialized_payload do
|
|
8
|
+
serialize_collection(paginated_collection)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def paginated_collection
|
|
15
|
+
collection.page(params[:page]).per(params[:per_page])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def collection
|
|
19
|
+
@collection ||= begin
|
|
20
|
+
base_scope = scope
|
|
21
|
+
|
|
22
|
+
if params[:q].present?
|
|
23
|
+
@search = base_scope.ransack(params[:q])
|
|
24
|
+
@search.result
|
|
25
|
+
else
|
|
26
|
+
base_scope
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def scope
|
|
32
|
+
model_class.joins(:location_vendor_places)
|
|
33
|
+
.where(location_vendor_places: { tenant_id: @tenant.id })
|
|
34
|
+
.distinct
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def model_class
|
|
38
|
+
SpreeCmCommissioner::Place
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def collection_serializer
|
|
42
|
+
SpreeCmCommissioner::V2::Storefront::TripPlaceSerializer
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Tenant
|
|
5
|
+
class TripSearchController < BaseController
|
|
6
|
+
CACHE_EXPIRES_IN = 5.minutes
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
render_serialized_payload do
|
|
10
|
+
Rails.cache.fetch(collection_cache_key, collection_cache_opts) do
|
|
11
|
+
trips = SpreeCmCommissioner::TripQuery.new(
|
|
12
|
+
origin_id: params[:origin_id],
|
|
13
|
+
destination_id: params[:destination_id],
|
|
14
|
+
date: params[:date],
|
|
15
|
+
route_type: params[:route_type],
|
|
16
|
+
number_of_guests: params[:number_of_guests],
|
|
17
|
+
tenant_id: @tenant.id,
|
|
18
|
+
params: params
|
|
19
|
+
).call
|
|
20
|
+
|
|
21
|
+
serialize_collection(trips)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# override from ContentCacheable
|
|
29
|
+
def max_age
|
|
30
|
+
CACHE_EXPIRES_IN.to_i
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# override
|
|
34
|
+
def collection_cache_key
|
|
35
|
+
cache_key_parts = [
|
|
36
|
+
'trip_search',
|
|
37
|
+
@tenant.id,
|
|
38
|
+
params[:origin_id],
|
|
39
|
+
params[:destination_id],
|
|
40
|
+
params[:date],
|
|
41
|
+
params[:route_type],
|
|
42
|
+
params[:number_of_guests],
|
|
43
|
+
resource_includes&.sort&.join(','),
|
|
44
|
+
sparse_fields&.sort&.join(','),
|
|
45
|
+
serializer_params.to_json,
|
|
46
|
+
params[:page]&.to_s&.strip,
|
|
47
|
+
params[:per_page]&.to_s&.strip
|
|
48
|
+
].compact.join('-')
|
|
49
|
+
|
|
50
|
+
Digest::MD5.hexdigest(cache_key_parts)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# override
|
|
54
|
+
def collection_cache_opts
|
|
55
|
+
{
|
|
56
|
+
namespace: Spree::Api::Config[:api_v2_collection_cache_namespace],
|
|
57
|
+
expires_in: CACHE_EXPIRES_IN
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# override
|
|
62
|
+
def default_resource_includes
|
|
63
|
+
[
|
|
64
|
+
'trips.vendor',
|
|
65
|
+
'trips.vendor.logo',
|
|
66
|
+
'trips.vehicle',
|
|
67
|
+
'trips.vehicle.vehicle_photos',
|
|
68
|
+
'trips.amenities'
|
|
69
|
+
]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def serialize_collection(collection)
|
|
73
|
+
serialized_data = SpreeCmCommissioner::V2::Storefront::TripQueryResultSerializer.new(
|
|
74
|
+
collection,
|
|
75
|
+
include: default_resource_includes,
|
|
76
|
+
params: serializer_params
|
|
77
|
+
).serializable_hash
|
|
78
|
+
serialized_data[:meta] = {
|
|
79
|
+
count: collection.size,
|
|
80
|
+
total_count: collection.respond_to?(:total_count) ? collection.total_count : collection.size,
|
|
81
|
+
current_page: collection.respond_to?(:current_page) ? collection.current_page : 1,
|
|
82
|
+
per_page: collection.respond_to?(:limit_value) ? collection.limit_value : collection.size,
|
|
83
|
+
pages: collection.respond_to?(:total_pages) ? collection.total_pages : 1,
|
|
84
|
+
next_page: collection.respond_to?(:next_page) ? collection.next_page : nil,
|
|
85
|
+
prev_page: collection.respond_to?(:prev_page) ? collection.prev_page : nil
|
|
86
|
+
}
|
|
87
|
+
serialized_data
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# override
|
|
91
|
+
def serializer_params
|
|
92
|
+
params.permit(:include).to_hash
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# override
|
|
96
|
+
def required_schema
|
|
97
|
+
SpreeCmCommissioner::TripSearchRequestSchema
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Tenant
|
|
5
|
+
class TripsController < BaseController
|
|
6
|
+
def show
|
|
7
|
+
resource = scope.find(params[:id])
|
|
8
|
+
|
|
9
|
+
render_serialized_payload do
|
|
10
|
+
serialize_resource(resource)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def scope
|
|
17
|
+
model_class.joins(:vendor)
|
|
18
|
+
.where(spree_vendors: { tenant_id: @tenant.id })
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def model_class
|
|
22
|
+
SpreeCmCommissioner::Trip
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def resource_serializer
|
|
26
|
+
SpreeCmCommissioner::V2::Storefront::TripSerializer
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -48,6 +48,8 @@ module SpreeCmCommissioner
|
|
|
48
48
|
name: 'ticket-type',
|
|
49
49
|
presentation: 'Ticket Type'
|
|
50
50
|
)
|
|
51
|
+
# auto assign the option type to the ticket
|
|
52
|
+
@ticket.option_types << @option_type unless @ticket.option_types.include?(@option_type)
|
|
51
53
|
|
|
52
54
|
@option_value = Spree::OptionValue.find_or_create_by!(
|
|
53
55
|
name: @ticket.name,
|
|
@@ -37,22 +37,21 @@ module Spree
|
|
|
37
37
|
|
|
38
38
|
def setup_tenant_and_store
|
|
39
39
|
@tenant = @order.tenant
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@current_store = @order.store
|
|
46
|
-
end
|
|
40
|
+
@current_store = @order.store
|
|
41
|
+
return if @tenant.blank?
|
|
42
|
+
|
|
43
|
+
@brand_color = @tenant.preferences[:brand_primary_color]
|
|
44
|
+
@vendor_logo_url = @tenant.active_vendor&.logo&.original_url
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
def build_subject(resend)
|
|
50
48
|
prefix = resend ? "[#{Spree.t(:resend).upcase}] " : ''
|
|
51
|
-
|
|
49
|
+
store_name = @tenant.present? ? @tenant.name : @current_store&.name
|
|
50
|
+
"#{prefix}#{store_name} Booking Confirmation ##{@order.number}"
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def store_url
|
|
55
|
-
@tenant.present? ? @
|
|
54
|
+
@tenant.present? ? @tenant.url : @current_store.url
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
def ticket_email(guest, email)
|
|
@@ -50,9 +50,9 @@ module SpreeCmCommissioner
|
|
|
50
50
|
private
|
|
51
51
|
|
|
52
52
|
def tenant_link_or_default(tenant, default_link)
|
|
53
|
-
return default_link unless tenant.respond_to?(:
|
|
53
|
+
return default_link unless tenant.respond_to?(:url)
|
|
54
54
|
|
|
55
|
-
site = tenant.
|
|
55
|
+
site = tenant.url.to_s.strip
|
|
56
56
|
site.presence || default_link
|
|
57
57
|
rescue StandardError
|
|
58
58
|
default_link
|
|
@@ -6,6 +6,7 @@ module SpreeCmCommissioner
|
|
|
6
6
|
preference :sms_sender_id, :string
|
|
7
7
|
preference :telegram_order_alert_chat_id, :string
|
|
8
8
|
preference :telegram_order_request_alert_chat_id, :string
|
|
9
|
+
preference :telegram_new_vendor_alert_chat_id, :string
|
|
9
10
|
preference :assetlinks, :string, default: ''
|
|
10
11
|
preference :apple_app_site_association, :string, default: ''
|
|
11
12
|
end
|
|
@@ -4,6 +4,8 @@ module SpreeCmCommissioner
|
|
|
4
4
|
|
|
5
5
|
belongs_to :product, class_name: '::Spree::Product', optional: false
|
|
6
6
|
|
|
7
|
+
has_one :banner, as: :viewable, dependent: :destroy, class_name: 'SpreeCmCommissioner::ProductCompletionStepBanner'
|
|
8
|
+
|
|
7
9
|
# When a completion step is changed, regenerate completion steps for all line items
|
|
8
10
|
# of the product so they reflect the latest step configuration.
|
|
9
11
|
after_destroy :regenerate_line_items_completion_steps
|
|
@@ -28,7 +30,8 @@ module SpreeCmCommissioner
|
|
|
28
30
|
action_label: action_label,
|
|
29
31
|
action_url: action_url_for(line_item),
|
|
30
32
|
completed_at: existing_data&.dig('completed_at'),
|
|
31
|
-
completed: completed?(line_item)
|
|
33
|
+
completed: completed?(line_item),
|
|
34
|
+
banner_url: banner.present? ? banner.original_url : nil
|
|
32
35
|
}
|
|
33
36
|
end
|
|
34
37
|
|
|
@@ -5,6 +5,7 @@ module SpreeCmCommissioner
|
|
|
5
5
|
# - https://t.me/ThePlatformKHBot?start={order.number}
|
|
6
6
|
# - https://example.com?guest_name={guests[0].first_name}&phone={guests[0].phone_number}
|
|
7
7
|
# - https://example.com?line_item_id={line_item.id}&quantity={line_item.quantity}
|
|
8
|
+
# - https://example.com?bill_address.first_name={bill_address.first_name}&bill_address.lastname={bill_address.lastname}
|
|
8
9
|
preference :entry_point_link, :string
|
|
9
10
|
|
|
10
11
|
# Allowed fields per object (excludes private/reference fields like *_id, *_by_id, metadata, etc.)
|
|
@@ -14,7 +15,11 @@ module SpreeCmCommissioner
|
|
|
14
15
|
state
|
|
15
16
|
email
|
|
16
17
|
total
|
|
18
|
+
display_total
|
|
17
19
|
item_total
|
|
20
|
+
display_item_total
|
|
21
|
+
adjustment_total
|
|
22
|
+
display_adjustment_total
|
|
18
23
|
created_at
|
|
19
24
|
completed_at
|
|
20
25
|
token
|
|
@@ -23,12 +28,31 @@ module SpreeCmCommissioner
|
|
|
23
28
|
currency
|
|
24
29
|
item_count
|
|
25
30
|
channel
|
|
31
|
+
special_instructions
|
|
32
|
+
].freeze
|
|
33
|
+
|
|
34
|
+
BILL_ADDRESS_ALLOWED_FIELDS = %w[
|
|
35
|
+
first_name
|
|
36
|
+
last_name
|
|
37
|
+
full_name
|
|
38
|
+
address1
|
|
39
|
+
address2
|
|
40
|
+
city
|
|
41
|
+
zipcode
|
|
42
|
+
phone
|
|
43
|
+
state_name
|
|
44
|
+
alternative_phone
|
|
45
|
+
company
|
|
46
|
+
label
|
|
47
|
+
age
|
|
48
|
+
gender
|
|
26
49
|
].freeze
|
|
27
50
|
|
|
28
51
|
LINE_ITEM_ALLOWED_FIELDS = %w[
|
|
29
52
|
qr_data
|
|
30
53
|
quantity
|
|
31
54
|
price
|
|
55
|
+
display_price
|
|
32
56
|
from_date
|
|
33
57
|
to_date
|
|
34
58
|
number
|
|
@@ -45,7 +69,6 @@ module SpreeCmCommissioner
|
|
|
45
69
|
dob
|
|
46
70
|
gender
|
|
47
71
|
age
|
|
48
|
-
email
|
|
49
72
|
phone_number
|
|
50
73
|
address
|
|
51
74
|
seat_number
|
|
@@ -60,9 +83,6 @@ module SpreeCmCommissioner
|
|
|
60
83
|
expectation
|
|
61
84
|
other_occupation
|
|
62
85
|
other_organization
|
|
63
|
-
entry_type
|
|
64
|
-
upload_later
|
|
65
|
-
data_fill_stage_phase
|
|
66
86
|
created_at
|
|
67
87
|
updated_at
|
|
68
88
|
].freeze
|
|
@@ -72,32 +92,79 @@ module SpreeCmCommissioner
|
|
|
72
92
|
return nil if preferred_entry_point_link.blank?
|
|
73
93
|
|
|
74
94
|
url = preferred_entry_point_link.dup
|
|
95
|
+
url = replace_order_placeholders(url, line_item)
|
|
96
|
+
url = replace_bill_address_placeholders(url, line_item)
|
|
97
|
+
url = replace_line_item_placeholders(url, line_item)
|
|
98
|
+
|
|
99
|
+
replace_guest_placeholders(url, line_item)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def completed?(line_item)
|
|
103
|
+
return false if line_item.completion_steps.blank?
|
|
104
|
+
|
|
105
|
+
step_data = line_item.completion_steps.find { |step| step['position'].to_s == position.to_s }
|
|
106
|
+
step_data&.dig('completed_at').present?
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Returns a hash of all supported placeholder fields grouped by object type.
|
|
110
|
+
# Used by the admin UI to display available placeholders when configuring the entry_point_link template.
|
|
111
|
+
# Example usage in template: {order.number}, {bill_address.first_name}, {line_item.quantity}, {guests[0].email}
|
|
112
|
+
#
|
|
113
|
+
# @return [Hash] Hash with keys :order, :bill_address, :line_item, :guests
|
|
114
|
+
# Each key maps to an array of allowed field names for that object type
|
|
115
|
+
def supported_fields
|
|
116
|
+
{
|
|
117
|
+
order: ORDER_ALLOWED_FIELDS,
|
|
118
|
+
bill_address: BILL_ADDRESS_ALLOWED_FIELDS,
|
|
119
|
+
line_item: LINE_ITEM_ALLOWED_FIELDS,
|
|
120
|
+
guests: GUEST_ALLOWED_FIELDS
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private
|
|
75
125
|
|
|
76
|
-
|
|
77
|
-
line_item.order.
|
|
78
|
-
|
|
126
|
+
def replace_order_placeholders(url, line_item)
|
|
127
|
+
return url if line_item.order.blank?
|
|
128
|
+
|
|
129
|
+
ORDER_ALLOWED_FIELDS.each do |field|
|
|
130
|
+
value = line_item.order.public_send(field)
|
|
131
|
+
url.gsub!("{order.#{field}}", value.to_s) if value.present?
|
|
79
132
|
end
|
|
80
133
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
134
|
+
url
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def replace_bill_address_placeholders(url, line_item)
|
|
138
|
+
return url if line_item.order&.bill_address.blank?
|
|
139
|
+
|
|
140
|
+
BILL_ADDRESS_ALLOWED_FIELDS.each do |field|
|
|
141
|
+
value = line_item.order.bill_address.public_send(field)
|
|
142
|
+
url.gsub!("{bill_address.#{field}}", value.to_s) if value.present?
|
|
84
143
|
end
|
|
85
144
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
145
|
+
url
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def replace_line_item_placeholders(url, line_item)
|
|
149
|
+
LINE_ITEM_ALLOWED_FIELDS.each do |field|
|
|
150
|
+
value = line_item.public_send(field)
|
|
151
|
+
url.gsub!("{line_item.#{field}}", value.to_s) if value.present?
|
|
91
152
|
end
|
|
92
153
|
|
|
93
154
|
url
|
|
94
155
|
end
|
|
95
156
|
|
|
96
|
-
def
|
|
97
|
-
return
|
|
157
|
+
def replace_guest_placeholders(url, line_item)
|
|
158
|
+
return url if line_item.guests.blank?
|
|
98
159
|
|
|
99
|
-
|
|
100
|
-
|
|
160
|
+
line_item.guests.each_with_index do |guest, index|
|
|
161
|
+
GUEST_ALLOWED_FIELDS.each do |field|
|
|
162
|
+
value = guest.public_send(field)
|
|
163
|
+
url.gsub!("{guests[#{index}].#{field}}", value.to_s) if value.present?
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
url
|
|
101
168
|
end
|
|
102
169
|
end
|
|
103
170
|
end
|
|
@@ -12,7 +12,10 @@ module SpreeCmCommissioner
|
|
|
12
12
|
through: :vendors,
|
|
13
13
|
source: :payment_methods
|
|
14
14
|
|
|
15
|
-
validates :host,
|
|
15
|
+
validates :host, presence: true, uniqueness: true,
|
|
16
|
+
format: { without: %r{\Ahttps?://},
|
|
17
|
+
message: :format
|
|
18
|
+
}
|
|
16
19
|
|
|
17
20
|
enum state: { enabled: 0, disabled: 1 }
|
|
18
21
|
|
|
@@ -22,6 +25,12 @@ module SpreeCmCommissioner
|
|
|
22
25
|
vendors.where(state: :active).first
|
|
23
26
|
end
|
|
24
27
|
|
|
28
|
+
def url
|
|
29
|
+
return if host.blank?
|
|
30
|
+
|
|
31
|
+
Rails.env.development? || Rails.env.test? ? "http://#{host}" : "https://#{host}"
|
|
32
|
+
end
|
|
33
|
+
|
|
25
34
|
private
|
|
26
35
|
|
|
27
36
|
def generate_slug
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
class VendorPlace < Base
|
|
3
|
-
enum place_type: {
|
|
3
|
+
enum place_type: { venue: 0, branch: 1, stop: 2, location: 3 }
|
|
4
4
|
acts_as_list scope: :vendor
|
|
5
5
|
|
|
6
|
+
belongs_to :tenant, class_name: 'SpreeCmCommissioner::Tenant', optional: true
|
|
6
7
|
belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
|
|
7
8
|
belongs_to :place, class_name: 'SpreeCmCommissioner::Place', optional: false
|
|
8
9
|
belongs_to :location, class_name: 'SpreeCmCommissioner::VendorPlace', optional: true
|
|
@@ -16,6 +17,8 @@ module SpreeCmCommissioner
|
|
|
16
17
|
|
|
17
18
|
accepts_nested_attributes_for :place, allow_destroy: true
|
|
18
19
|
|
|
20
|
+
before_save :set_tenant_id
|
|
21
|
+
|
|
19
22
|
# include place when using these delegate to avoid N+1
|
|
20
23
|
def display_name
|
|
21
24
|
place&.name
|
|
@@ -28,5 +31,11 @@ module SpreeCmCommissioner
|
|
|
28
31
|
def selected
|
|
29
32
|
vendor.selected_place_references.include?(place&.reference)
|
|
30
33
|
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def set_tenant_id
|
|
38
|
+
self.tenant_id = vendor&.tenant_id
|
|
39
|
+
end
|
|
31
40
|
end
|
|
32
41
|
end
|
|
@@ -37,6 +37,15 @@
|
|
|
37
37
|
<% end %>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
|
+
<!-- Telegram New Vendor Alert Chat ID -->
|
|
41
|
+
<div class="col-6">
|
|
42
|
+
<%= f.field_container :preferred_telegram_new_vendor_alert_chat_id do %>
|
|
43
|
+
<%= f.label :preferred_telegram_new_vendor_alert_chat_id, Spree.t(:telegram_new_vendor_alert_chat_id) %>
|
|
44
|
+
<%= f.text_field :preferred_telegram_new_vendor_alert_chat_id, class: 'form-control' %>
|
|
45
|
+
<%= f.error_message_on :preferred_telegram_new_vendor_alert_chat_id %>
|
|
46
|
+
<% end %>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
40
49
|
<!-- Assetlinks -->
|
|
41
50
|
<div class="col-12">
|
|
42
51
|
<%= f.field_container :preferred_assetlinks do %>
|