20 lines
710 B
Ruby
20 lines
710 B
Ruby
class AsiaExhibition
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include Slug
|
|
field :exhibition_name, :type => String, :default => "", :localize => true, :as => :slug_title
|
|
field :exhibition_start_date, :type => Date
|
|
field :exhibition_end_date, :type => Date
|
|
field :host, :type => String, :default => "", :localize => true
|
|
field :rss2_id
|
|
belongs_to :asia_teacher, index: true
|
|
scope :sort_order, ->{order({exhibition_start_date: -1})}
|
|
index({exhibition_start_date: -1}, { unique: false, background: true })
|
|
def exhibition_date
|
|
if self.exhibition_start_date.nil? && self.exhibition_end_date.nil?
|
|
""
|
|
else
|
|
"#{self.exhibition_start_date} ~ #{self.exhibition_end_date}"
|
|
end
|
|
end
|
|
end |