class Bulletin include Mongoid::Document include Mongoid::Timestamps include OrbitModel::Status include OrbitModel::Impression include OrbitTag::Taggable include OrbitCategory::Categorizable include Slug field :title, as: :slug_title, type: String, localize: true field :subtitle, localize: true field :text, localize: true field :create_user_id field :update_user_id field :public, :type => Boolean, :default => true field :postdate , :type => DateTime, :default => Time.now field :deadline , :type => DateTime field :email_sent, :type => Boolean, :default => false field :email_sentdate , :type => DateTime field :email_user_ids field :other_mailaddress mount_uploader :image, ImageUploader has_many :bulletin_links, :autosave => true, :dependent => :destroy has_many :bulletin_files, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :bulletin_files, :allow_destroy => true accepts_nested_attributes_for :bulletin_links, :allow_destroy => true def update_user User.find(update_user_id) rescue nil end def update_user=(user) self.update_user_id = user.id end def self.can_display() self.any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}) end end