2015-10-23 06:50:07 +00:00
|
|
|
require 'net/http'
|
2019-10-26 07:36:04 +00:00
|
|
|
class AlbumImage
|
2014-05-05 06:07:18 +00:00
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitTag::Taggable
|
|
|
|
mount_uploader :file, GalleryUploader
|
|
|
|
field :title
|
2021-04-04 05:03:24 +00:00
|
|
|
field :title_translations, type: Hash, default: {}
|
2014-05-05 06:07:18 +00:00
|
|
|
field :description, localize: true
|
2014-06-13 08:15:13 +00:00
|
|
|
field :rss2_id, type: String
|
2016-06-28 08:40:23 +00:00
|
|
|
field :order, type: Integer, default: -1
|
2021-04-04 05:03:24 +00:00
|
|
|
|
2014-05-05 06:07:18 +00:00
|
|
|
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
2021-04-04 05:03:24 +00:00
|
|
|
def title_translations
|
|
|
|
tmp = super || {}
|
|
|
|
if tmp == {}
|
|
|
|
tmp = I18n.available_locales.collect{|locale| [locale,self[:title]]}.to_h
|
|
|
|
end
|
|
|
|
tmp
|
|
|
|
end
|
|
|
|
def title
|
|
|
|
self.title_translations[I18n.locale]
|
|
|
|
end
|
2014-05-05 06:07:18 +00:00
|
|
|
belongs_to :album
|
2019-09-25 06:53:46 +00:00
|
|
|
has_many :album_crops, :autosave => true, :dependent => :destroy
|
|
|
|
accepts_nested_attributes_for :album_crops, :allow_destroy => true
|
2014-05-05 06:07:18 +00:00
|
|
|
end
|