Merge branch 'master' into 'master'
Fix bug. See merge request spen/seminar!34
This commit is contained in:
commit
5331a6ba8b
|
@ -176,7 +176,8 @@ class SeminarMain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
after_initialize do
|
after_initialize do
|
||||||
unless self.new_record?
|
unless self.new_record? || @triggered_initialize
|
||||||
|
@triggered_initialize = true
|
||||||
save_flag = false
|
save_flag = false
|
||||||
seminar_reviews = self.seminar_reviews
|
seminar_reviews = self.seminar_reviews
|
||||||
if seminar_reviews.present?
|
if seminar_reviews.present?
|
||||||
|
|
|
@ -20,31 +20,38 @@ class SeminarReview
|
||||||
field :seminar_session_ids
|
field :seminar_session_ids
|
||||||
belongs_to :seminar_main
|
belongs_to :seminar_main
|
||||||
after_initialize do
|
after_initialize do
|
||||||
unless self.new_record?
|
unless self.new_record? || @triggered_initialize
|
||||||
|
@triggered_initialize = true
|
||||||
save_flag = false
|
save_flag = false
|
||||||
|
destroy_flag = false
|
||||||
if (self.reviewer_id.class == Array rescue false)
|
if (self.reviewer_id.class == Array rescue false)
|
||||||
reviewer_ids = self.reviewer_id[1..-1]
|
reviewer_ids = self.reviewer_id[1..-1]
|
||||||
reviewer_ids.each do |reviewer_id|
|
reviewer_ids.each do |reviewer_id|
|
||||||
self.class.create(:reviewer_id=>reviewer_id,:seminar_main=>self.seminar_main)
|
self.class.create(:reviewer_id=>reviewer_id,:seminar_main_id=>self.seminar_main_id)
|
||||||
end
|
end
|
||||||
self.reviewer_id = self.reviewer_id.first
|
self.reviewer_id = self.reviewer_id.first
|
||||||
save_flag = true
|
save_flag = true
|
||||||
|
elsif self[:reviewer_id].nil?
|
||||||
|
self.destroy
|
||||||
|
destroy_flag = true
|
||||||
end
|
end
|
||||||
if (self.session_ids.nil? rescue true)
|
if !destroy_flag
|
||||||
session_ids = []
|
if (self.session_ids.nil? rescue true)
|
||||||
self.default_topics.each_with_index do |t,i|
|
session_ids = []
|
||||||
next if t != "seminar_signup_contributes.description"
|
self.default_topics.each_with_index do |t,i|
|
||||||
session_ids << self.default_topics_values[i]
|
next if t != "seminar_signup_contributes.description"
|
||||||
|
session_ids << self.default_topics_values[i]
|
||||||
|
end
|
||||||
|
session_ids = session_ids.flatten.map{|i| i.to_i}
|
||||||
|
self.session_ids = session_ids
|
||||||
|
save_flag = true
|
||||||
end
|
end
|
||||||
session_ids = session_ids.flatten.map{|i| i.to_i}
|
if self.seminar_session_ids.nil? && self.session_ids.class == Array
|
||||||
self.session_ids = session_ids
|
self.seminar_session_ids = SeminarSession.where(:seminar_main_id=>self.seminar_main_id,:key.in=>self.session_ids).pluck(:id) rescue nil
|
||||||
save_flag = true
|
save_flag = true
|
||||||
|
end
|
||||||
|
self.save(:validate=>false) if save_flag
|
||||||
end
|
end
|
||||||
if self.seminar_session_ids.nil? && self.session_ids.class == Array
|
|
||||||
self.seminar_session_ids = self.seminar_main.seminar_sessions.where(:key.in=>self.session_ids).pluck(:id) rescue nil
|
|
||||||
save_flag = true
|
|
||||||
end
|
|
||||||
self.save(:validate=>false) if save_flag
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
before_save do
|
before_save do
|
||||||
|
@ -60,12 +67,12 @@ class SeminarReview
|
||||||
default_seminar_signup_ids += SeminarSignupContribute.where(:id.in=>seminar_signup_contribute_ids).pluck(:seminar_signup_id)
|
default_seminar_signup_ids += SeminarSignupContribute.where(:id.in=>seminar_signup_contribute_ids).pluck(:seminar_signup_id)
|
||||||
elsif fn == "seminar_signup_contributes"
|
elsif fn == "seminar_signup_contributes"
|
||||||
seminar_signup_ids_from_contribute = SeminarSignupContribute.where(:description.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id)
|
seminar_signup_ids_from_contribute = SeminarSignupContribute.where(:description.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id)
|
||||||
seminar_signup_ids_from_contribute = seminar_signup_ids_from_contribute & (self.seminar_main.seminar_signups.pluck(:id) rescue [])
|
seminar_signup_ids_from_contribute = seminar_signup_ids_from_contribute & (SeminarSignup.where(:seminar_main_id=>self.seminar_main_id).pluck(:id) rescue [])
|
||||||
default_seminar_signup_ids += seminar_signup_ids_from_contribute
|
default_seminar_signup_ids += seminar_signup_ids_from_contribute
|
||||||
self.session_ids = self.session_ids.concat(self.default_topics_values[i].map{|v| v.to_i})
|
self.session_ids = self.session_ids.concat(self.default_topics_values[i].map{|v| v.to_i})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.seminar_session_ids = self.seminar_main.seminar_sessions.where(:key.in=>self.session_ids.to_a).pluck(:id) rescue []
|
self.seminar_session_ids = SeminarSession.where(:seminar_main_id=>self.seminar_main_id,:key.in=>self.session_ids.to_a).pluck(:id) rescue []
|
||||||
default_seminar_signup_ids.uniq!
|
default_seminar_signup_ids.uniq!
|
||||||
default_seminar_signup_ids = default_seminar_signup_ids.map{|s| s.to_s}
|
default_seminar_signup_ids = default_seminar_signup_ids.map{|s| s.to_s}
|
||||||
self.default_seminar_signup_ids = default_seminar_signup_ids
|
self.default_seminar_signup_ids = default_seminar_signup_ids
|
||||||
|
|
Loading…
Reference in New Issue