dscf-core 0.3.12 → 0.3.14
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/core/auth_controller.rb +6 -2
- data/app/models/concerns/dscf/core/attachment_urls.rb +31 -0
- data/app/models/dscf/core/business.rb +2 -3
- data/app/models/dscf/core/document.rb +3 -3
- data/app/serializers/dscf/core/business_serializer.rb +14 -1
- data/lib/dscf/core/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 04dc0626657988f601694e4e423b72fbc82996d6960178bc52024aa1de41bfe8
|
|
4
|
+
data.tar.gz: 9270c931ab649cf64b2265e0680ea36cdea14c85cb7d73439e66035a4336bae1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 369e0eb673118c48fafb0c41ab308a926cda01ba05348047db3907fa988ca569185c9f5c899f9a5d560ed728271b2bc273baed41abe2a62695eca5171d52ef88
|
|
7
|
+
data.tar.gz: fa2cc032c4fb2ce73478517a353896dd03dc36717a05839b8fde475308d41215d0b396cde8aa935a1fed48ffe9b5b437909c067a5548434d048fed3ce808fbd0
|
|
@@ -161,8 +161,12 @@ module Dscf
|
|
|
161
161
|
# agent from it rather than trusting a client-supplied agent_id
|
|
162
162
|
# (there is none in this params shape today, but this keeps the
|
|
163
163
|
# same trust model as the rest of the agent-assisted flows).
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
# Guard on current_user first: find_by(user_id: nil) matches any
|
|
165
|
+
# Agent row with a null user_id, silently attributing anonymous
|
|
166
|
+
# self-signups to a random agent (confirmed live in dscf_marketplace's
|
|
167
|
+
# equivalent bug — same fix applied here).
|
|
168
|
+
onboarding_agent = if current_user && defined?(Dscf::Marketplace::Agent)
|
|
169
|
+
Dscf::Marketplace::Agent.find_by(user_id: current_user.id)
|
|
166
170
|
end
|
|
167
171
|
|
|
168
172
|
retailer = Dscf::Marketplace::Retailer.create!(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Core
|
|
3
|
+
# Shared Active Storage URL helper for plain has_one_attached/
|
|
4
|
+
# has_many_attached models (distinct from the custom Attachable/
|
|
5
|
+
# FileAttachment system). Produces a host-aware proxy URL — unlike
|
|
6
|
+
# `only_path: true`, which drops the host entirely and can't be used to
|
|
7
|
+
# build an <img src> from a separate frontend origin.
|
|
8
|
+
module AttachmentUrls
|
|
9
|
+
extend ActiveSupport::Concern
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def attachment_url_for(attachment)
|
|
14
|
+
return unless attachment.present?
|
|
15
|
+
return if attachment.respond_to?(:attached?) && !attachment.attached?
|
|
16
|
+
|
|
17
|
+
Rails.application.routes.url_helpers.rails_storage_proxy_url(attachment, **active_storage_url_options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def active_storage_url_options
|
|
21
|
+
url_options = Rails.application.config.x.active_storage_url_options.presence ||
|
|
22
|
+
Rails.application.routes.default_url_options.presence ||
|
|
23
|
+
Rails.application.config.action_controller.default_url_options.presence ||
|
|
24
|
+
Rails.application.config.action_mailer.default_url_options.presence ||
|
|
25
|
+
{}
|
|
26
|
+
|
|
27
|
+
url_options.to_h.symbolize_keys.compact
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -5,6 +5,7 @@ module Dscf
|
|
|
5
5
|
belongs_to :business_type, class_name: "Dscf::Core::BusinessType"
|
|
6
6
|
|
|
7
7
|
include Dscf::Core::ReviewableModel
|
|
8
|
+
include Dscf::Core::AttachmentUrls
|
|
8
9
|
|
|
9
10
|
has_one_attached :logo
|
|
10
11
|
|
|
@@ -15,9 +16,7 @@ module Dscf
|
|
|
15
16
|
validates :name, presence: true
|
|
16
17
|
|
|
17
18
|
def logo_url
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Rails.application.routes.url_helpers.rails_storage_proxy_url(logo, only_path: true)
|
|
19
|
+
attachment_url_for(logo)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def self.ransackable_attributes(_auth_object = nil)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Dscf
|
|
2
2
|
module Core
|
|
3
3
|
class Document < ApplicationRecord
|
|
4
|
+
include Dscf::Core::AttachmentUrls
|
|
5
|
+
|
|
4
6
|
belongs_to :documentable, polymorphic: true
|
|
5
7
|
belongs_to :verified_by, polymorphic: true, optional: true
|
|
6
8
|
validates :document_type, presence: true
|
|
@@ -11,9 +13,7 @@ module Dscf
|
|
|
11
13
|
def file_urls
|
|
12
14
|
return [] unless files.attached?
|
|
13
15
|
|
|
14
|
-
files.map
|
|
15
|
-
Rails.application.routes.url_helpers.rails_storage_proxy_url(file, only_path: true)
|
|
16
|
-
end
|
|
16
|
+
files.map { |file| attachment_url_for(file) }
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
module Dscf
|
|
2
2
|
module Core
|
|
3
3
|
class BusinessSerializer < ActiveModel::Serializer
|
|
4
|
-
attributes :id, :name, :description, :contact_email, :contact_phone, :tin_number, :created_at, :updated_at,
|
|
4
|
+
attributes :id, :name, :description, :contact_email, :contact_phone, :tin_number, :created_at, :updated_at,
|
|
5
|
+
:is_system, :logo_url, :review_status, :review_reason
|
|
5
6
|
|
|
6
7
|
belongs_to :user, serializer: Dscf::Core::UserSerializer
|
|
7
8
|
belongs_to :business_type, serializer: Dscf::Core::BusinessTypeSerializer
|
|
8
9
|
has_many :reviews, serializer: Dscf::Core::ReviewSerializer
|
|
9
10
|
has_many :documents, serializer: Dscf::Core::DocumentSerializer
|
|
11
|
+
|
|
12
|
+
def review_status
|
|
13
|
+
object.current_status_for(:default)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Reason the admin gave on the latest review (modification request or
|
|
17
|
+
# rejection), so the owner can see why without needing the push
|
|
18
|
+
# notification. nil for approved/pending/draft.
|
|
19
|
+
def review_reason
|
|
20
|
+
feedback = object.current_review_for(:default)&.feedback
|
|
21
|
+
feedback && (feedback["reason"] || feedback[:reason])
|
|
22
|
+
end
|
|
10
23
|
end
|
|
11
24
|
end
|
|
12
25
|
end
|
data/lib/dscf/core/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dscf-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Asrat
|
|
@@ -469,6 +469,7 @@ files:
|
|
|
469
469
|
- app/jobs/dscf/core/audit_logger_job.rb
|
|
470
470
|
- app/mailers/dscf/core/application_mailer.rb
|
|
471
471
|
- app/models/concerns/dscf/core/attachable.rb
|
|
472
|
+
- app/models/concerns/dscf/core/attachment_urls.rb
|
|
472
473
|
- app/models/concerns/dscf/core/auditable_model.rb
|
|
473
474
|
- app/models/concerns/dscf/core/notifiable.rb
|
|
474
475
|
- app/models/concerns/dscf/core/reviewable_model.rb
|