2018-03-06 13:44:29 +01:00
|
|
|
class Cerfa < ApplicationRecord
|
2017-10-24 18:12:25 +02:00
|
|
|
belongs_to :dossier, touch: true
|
2016-03-17 17:33:38 +01:00
|
|
|
belongs_to :user
|
2015-08-18 13:52:00 +02:00
|
|
|
|
|
|
|
mount_uploader :content, CerfaUploader
|
2018-01-16 13:34:24 +01:00
|
|
|
validates :content, :file_size => { :maximum => 20.megabytes }
|
2015-08-18 16:30:57 +02:00
|
|
|
|
|
|
|
def empty?
|
|
|
|
content.blank?
|
|
|
|
end
|
2016-02-26 13:59:03 +01:00
|
|
|
|
|
|
|
def content_url
|
2018-01-11 19:04:39 +01:00
|
|
|
if content.url.present?
|
2016-05-18 11:43:32 +02:00
|
|
|
if Features.remote_storage
|
|
|
|
(RemoteDownloader.new content.filename).url
|
|
|
|
else
|
2016-05-24 18:35:25 +02:00
|
|
|
(LocalDownloader.new content.path, 'CERFA').url
|
2016-05-13 16:08:51 +02:00
|
|
|
end
|
2016-02-26 13:59:03 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|