class PaperCriteria include Mongoid::Document include Mongoid::Timestamps include Slug field :title,as: :slug_title, localize: true field :description, localize: true field :start_date, type: DateTime field :end_date, type: DateTime field :sending_time, type: DateTime field :sending_title, localize: true field :sending_notes field :language_to_send, type: Array, :default => ["en","zh_tw"] field :receivers, type: Array, :default => ["subscriber"] field :other_emails field :invalid_emails, type: Array, :default => [] field :send_failed_emails, type: Array, :default => [] def epaper_topics tmp = EPaperTopic.where(:period.gte => self.start_date.in_time_zone(Time.zone.utc_offset / 3600), :period.lte => self.end_date.in_time_zone(Time.zone.utc_offset / 3600)).can_display tmp = EPaperTopic.where(:period.gte => self.start_date.in_time_zone(Time.zone.utc_offset / 3600), :period.lte => self.end_date.in_time_zone(Time.zone.utc_offset / 3600)).limit(1) if tmp.first.nil? tmp end def other_emails_ids if !self.other_emails.nil? return self.other_emails.split(",") else return [] end end end