e_paper/app/models/paper.rb

31 lines
689 B
Ruby

class Paper
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitTag::Taggable
include OrbitCategory::Categorizable
include Slug
field :title,as: :slug_title, localize: true
field :period, type: DateTime
field :description, localize: true
field :mailed, type: Boolean, default: false
field :ready_to_send, type: Boolean, default: false
has_many :topics, :dependent => :destroy
scope :can_display, ->{where(:is_hidden=>false,:title.ne => "").order_by([:is_top, :desc])}
def self.find_by_param(input)
self.find_by(uid: input)
end
def send_epaper
self.ready_to_send = true
self.save
end
end