2014-05-08 07:33:39 +00:00
|
|
|
class QaFile
|
|
|
|
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
|
|
|
|
mount_uploader :file, AssetUploader
|
|
|
|
|
|
|
|
field :description, localize: true
|
|
|
|
field :should_destroy, :type => Boolean
|
|
|
|
field :title, localize: true
|
2021-11-15 04:35:23 +00:00
|
|
|
field :choose_lang, :type => Array, :default => ["en","zh_tw"]
|
2014-05-08 07:33:39 +00:00
|
|
|
belongs_to :qa
|
2021-03-24 10:16:04 +00:00
|
|
|
def file_title
|
|
|
|
if self.description.present?
|
|
|
|
return self.description
|
|
|
|
elsif self.title.present?
|
|
|
|
return self.title
|
|
|
|
else
|
|
|
|
return File.basename(self.file.path)
|
|
|
|
end
|
|
|
|
end
|
2021-11-15 04:35:23 +00:00
|
|
|
def enabled_for?(lang)
|
|
|
|
if lang.nil?
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return self.choose_lang.include?(lang)
|
|
|
|
end
|
|
|
|
end
|
2014-05-08 07:33:39 +00:00
|
|
|
end
|