このコミットが含まれているのは:
2026-06-23 22:05:11 +09:00
コミット 507ce1680e
25個のファイルの変更1148行の追加111行の削除
+21 -3
ファイルの表示
@@ -2,7 +2,8 @@
module MaterialRepr
BASE = { only: [:id, :url, :created_at, :updated_at],
BASE = { only: [:id, :url, :version_no, :file_suppressed_at,
:file_suppression_reason, :created_at, :updated_at],
methods: [:content_type],
include: { tag: TagRepr::BASE,
created_by_user: UserRepr::BASE,
@@ -12,13 +13,30 @@ module MaterialRepr
def base material, host:
material.as_json(BASE).merge(
file: if material.file.attached?
file: if material.file.attached? && !material.file_suppressed?
Rails.application.routes.url_helpers.rails_storage_proxy_url(
material.file, host:)
end)
end,
export_paths: export_paths(material),
export_items: export_items(material))
end
def many materials, host:
materials.map { |m| base(m, host:) }
end
def export_paths material
material.material_export_items.each_with_object({ }) do |item, hash|
hash[item.profile] = item.enabled ? item.export_path : ''
end
end
def export_items material
material.material_export_items.map do |item|
{ id: item.id,
profile: item.profile,
export_path: item.export_path,
enabled: item.enabled }
end
end
end