Merge pull request #7184 from betagouv/US/sentry#3144617191

fix(sentry#3144617191): in manager, rendering an archive#show was broken. fix and enhance ui to know how big our archives are
This commit is contained in:
mfo 2022-04-21 17:55:36 +02:00 committed by GitHub
commit bbde926532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 12 deletions

View file

@ -12,7 +12,7 @@ class ArchiveDashboard < Administrate::BaseDashboard
created_at: Field::DateTime,
updated_at: Field::DateTime,
status: Field::String,
file: Field::HasOne
file: AttachmentField
}.freeze
# COLLECTION_ATTRIBUTES
@ -24,7 +24,8 @@ class ArchiveDashboard < Administrate::BaseDashboard
:id,
:created_at,
:updated_at,
:status
:status,
:file
].freeze
# SHOW_PAGE_ATTRIBUTES
@ -33,14 +34,6 @@ class ArchiveDashboard < Administrate::BaseDashboard
:id,
:created_at,
:updated_at,
:status,
:file
:status
].freeze
# Overwrite this method to customize how users are displayed
# across all pages of the admin dashboard.
#
def display_resource(archive)
"Archive : #{archive&.file.&byte_size}"
end
end

View file

@ -1,8 +1,9 @@
require "administrate/field/base"
class AttachmentField < Administrate::Field::Base
include ActionView::Helpers::NumberHelper
def to_s
data.filename.to_s
"#{data.filename} (#{number_to_human_size(data.byte_size)})"
end
def blob_path