Files
nairobi/app/models/concerns/documentable.rb
Javi Martín d14f6691dc Return document max file size in megabytes
The same way it's done for images.

We were converting the number of megabytes to bytes and then converting
it to megabytes again. Instead, we can leave it as it is and only
convert it to bytes when necessary (only one place).
2021-09-11 17:05:00 +02:00

23 lines
556 B
Ruby

module Documentable
extend ActiveSupport::Concern
included do
has_many :documents, as: :documentable, inverse_of: :documentable, dependent: :destroy
accepts_nested_attributes_for :documents, allow_destroy: true
end
module ClassMethods
def max_documents_allowed
Setting["uploads.documents.max_amount"].to_i
end
def max_file_size
Setting["uploads.documents.max_size"].to_i
end
def accepted_content_types
Setting["uploads.documents.content_types"]&.split(" ") || ["application/pdf"]
end
end
end