2012-01-31 10:31:31 +00:00
|
|
|
class AdBanner
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include Mongoid::MultiParameterAttributes
|
2013-08-05 10:30:35 +00:00
|
|
|
include OrbitTag::Taggable
|
2013-10-15 15:38:16 +00:00
|
|
|
include OrbitModel::Authorizable
|
2012-05-15 01:57:05 +00:00
|
|
|
|
2012-02-02 01:55:09 +00:00
|
|
|
field :ad_fx #TODO Design should explain
|
2013-10-18 07:25:19 +00:00
|
|
|
field :height, type: Integer
|
|
|
|
field :speed, type: Integer
|
|
|
|
field :title
|
|
|
|
field :timeout, type: Integer
|
|
|
|
field :width, type: Integer
|
2012-04-01 15:39:49 +00:00
|
|
|
|
|
|
|
has_many :ad_images , dependent: :delete
|
2012-05-14 04:34:15 +00:00
|
|
|
|
2013-10-18 07:25:19 +00:00
|
|
|
validates_uniqueness_of :title
|
|
|
|
validates :title, :length => { :minimum => 2 }
|
|
|
|
validates :height, :speed, :timeout, :width, :presence => true
|
2012-05-14 04:34:15 +00:00
|
|
|
|
2013-10-18 10:31:18 +00:00
|
|
|
FX_TYPES = %w(fade fadeout flipHorz flipVert scrollHorz scrollVert tileSlide tileBlind)
|
2012-06-20 06:50:51 +00:00
|
|
|
|
2013-10-18 07:25:19 +00:00
|
|
|
def size
|
|
|
|
"#{self.width} x #{self.height}"
|
2012-05-14 04:34:15 +00:00
|
|
|
end
|
|
|
|
|
2013-10-18 10:31:18 +00:00
|
|
|
def timeout_millisecond
|
2013-10-18 07:25:19 +00:00
|
|
|
self.timeout*1000 rescue 0
|
2012-04-23 09:03:55 +00:00
|
|
|
end
|
2012-02-02 01:55:09 +00:00
|
|
|
|
2012-01-31 10:31:31 +00:00
|
|
|
end
|