epaper/app/models/e_paper_topic.rb

29 lines
851 B
Ruby
Raw Normal View History

2019-05-28 15:54:32 +00:00
class EPaperTopic
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitCategory::Categorizable
include OrbitTag::Taggable
include Slug
field :title,as: :slug_title, localize: true
field :period, type: DateTime
field :description, localize: true
field :content, localize: true
field :mailed, type: Boolean, default: false
field :ready_to_send, type: Boolean, default: false
field :article_authors, type: Array, default: []
mount_uploader :image, ImageUploader
scope :can_display, ->{where(:is_hidden=>false,:title.ne => "").order_by([:period, :desc])}
def article_author_profiles
MemberProfile.find(self.article_authors)
end
def criteria_title
PaperCriteria.where(:start_date.lte => self.period, :end_date.gte => self.period).first.title rescue ""
end
end