25 lines
1.0 KiB
Ruby
25 lines
1.0 KiB
Ruby
|
class Coloncancerpredictrecord2
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
include OrbitModel::Status
|
||
|
include OrbitModel::Impression
|
||
|
# encoding: utf-8
|
||
|
include OrbitTag::Taggable
|
||
|
include OrbitCategory::Categorizable
|
||
|
field :title ,type:String ,default:""
|
||
|
field :submit_time ,type:String ,default:""
|
||
|
field :result , type:Hash , default:{}
|
||
|
field :names , type:Hash , default:{}
|
||
|
field :values , type:Hash , default:{}
|
||
|
field :submit_numbers , type:Fixnum , default: 1
|
||
|
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
|
||
|
scope :is_approved, ->{where(:approved => true)}
|
||
|
before_save :set_submit_times
|
||
|
def set_submit_times
|
||
|
self.submit_time = Coloncancerpredictrecord2.all.count + 1
|
||
|
end
|
||
|
def check_missing_data
|
||
|
missing_keys = self.names.keys - self.result.keys rescue []
|
||
|
missing_keys.each{|k| self.result[k] = "" }
|
||
|
end
|
||
|
end
|