21 lines
954 B
Ruby
21 lines
954 B
Ruby
|
# encoding: utf-8
|
||
|
class ApplicationFormSession
|
||
|
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
|
||
|
field :key
|
||
|
belongs_to :application_form_main
|
||
|
field :application_form_signup_ids, :type => Array, :default => []
|
||
|
field :application_form_signup_contribute_ids, :type => Array, :default => []
|
||
|
field :default_application_form_signup_ids, :type => Array, :default => []
|
||
|
def application_form_signups
|
||
|
ApplicationFormSignup.any_of({:id.in=>self.application_form_signup_ids},{:preferred_sessions=>self.key,:application_form_session_ids.in=>[[],nil]})
|
||
|
end
|
||
|
def fix_application_form_signup_contribute_ids
|
||
|
@application_form_signup_ids = ApplicationFormSignup.where(:id.in=>self.application_form_signup_ids).pluck(:id).map{|id| id.to_s}
|
||
|
self.application_form_signup_contribute_ids = ApplicationFormSignupContribute.where(:application_form_signup_id.in=>@application_form_signup_ids).pluck(:id).map{|id| id.to_s}
|
||
|
self.save
|
||
|
end
|
||
|
end
|