dscf-core 0.3.12 → 0.3.13
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1017e5f24b7c9e2082e34887e79c5f1f1efe0702aa9be9d51fe7e30f82f26975
|
|
4
|
+
data.tar.gz: f6f878a9c7dc8df5fd0823cf885a0a88366d0a2b08cdcbcb64898607d7701a50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38ef2bbb5e8ac7e0236e5dea4642350f82518c4b0bf3fcc4ae9f192512c4d5de656894c0c1406707110f3a6b819f9f217290ae0211950c87cccfc03ac58c5170
|
|
7
|
+
data.tar.gz: bf59dfc24369e0873ead51b1723dd6f14d76ccfe6aa1624e5d93740537090331e7cf9e11cf16f2a7cb4180a754e392104175fe29ece94bb7ff80230447e00ae8
|
|
@@ -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.13
|
|
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
|