30 lines
932 B
Ruby
Executable File
30 lines
932 B
Ruby
Executable File
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.in_time_zone(Time.zone.utc_offset / 3600), :end_date.gte => self.period.in_time_zone(Time.zone.utc_offset / 3600)).first.title rescue ""
|
|
end
|
|
end
|