2021-04-03 16:23:52 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
class SeminarSession
|
|
|
|
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
|
|
|
|
field :key
|
|
|
|
belongs_to :seminar_main
|
|
|
|
field :seminar_signup_ids, :type => Array, :default => []
|
2021-04-24 10:41:50 +00:00
|
|
|
field :seminar_signup_contribute_ids, :type => Array, :default => []
|
|
|
|
field :default_seminar_signup_ids, :type => Array, :default => []
|
2021-04-03 16:23:52 +00:00
|
|
|
def seminar_signups
|
2021-04-24 10:41:50 +00:00
|
|
|
SeminarSignup.any_of({:id.in=>self.seminar_signup_ids},{:preferred_sessions=>self.key,:seminar_session_ids.in=>[[],nil]})
|
|
|
|
end
|
|
|
|
def fix_seminar_signup_contribute_ids
|
|
|
|
@seminar_signup_ids = SeminarSignup.where(:id.in=>self.seminar_signup_ids).pluck(:id).map{|id| id.to_s}
|
|
|
|
self.seminar_signup_contribute_ids = SeminarSignupContribute.where(:seminar_signup_id.in=>@seminar_signup_ids).pluck(:id).map{|id| id.to_s}
|
|
|
|
self.save
|
2021-04-03 16:23:52 +00:00
|
|
|
end
|
|
|
|
end
|