This commit is contained in:
BoHung Chiu 2023-02-07 11:30:38 +08:00
parent a45db2488e
commit 3a59df9efb
2 changed files with 17 additions and 12 deletions

View File

@ -186,7 +186,12 @@ class SeminarMain
end end
end end
end end
after_initialize do after_destroy do
Thread.new do
Page.where(:bind_model=>self.class.to_s,:bind_uid=>self.uid).destroy
end
end
def migrate_old
unless self.new_record? || @triggered_initialize unless self.new_record? || @triggered_initialize
@triggered_initialize = true @triggered_initialize = true
save_flag = false save_flag = false
@ -234,11 +239,6 @@ class SeminarMain
self.save(:validate=>false) if save_flag self.save(:validate=>false) if save_flag
end end
end end
after_destroy do
Thread.new do
Page.where(:bind_model=>self.class.to_s,:bind_uid=>self.uid).destroy
end
end
def get_frontend_url(tmp_seminar_url, call_action=nil) def get_frontend_url(tmp_seminar_url, call_action=nil)
@enable_custom_template = self.enable_custom_template @enable_custom_template = self.enable_custom_template
if call_action.nil? if call_action.nil?

View File

@ -9,22 +9,27 @@ Rails.application.routes.draw do
update_flag = s.respond_to?(:tmp_flags) update_flag = s.respond_to?(:tmp_flags)
need_update1 = update_flag && !(s.tmp_flags.include?('fix_sr')) need_update1 = update_flag && !(s.tmp_flags.include?('fix_sr'))
need_update2 = !update_flag || !(s.tmp_flags.include?('smer1')) need_update2 = !update_flag || !(s.tmp_flags.include?('smer1'))
need_update3 = !update_flag || !(s.tmp_flags.include?('smer2'))
if need_update1 if need_update1
Page.where(:bind_model=>"SeminarMain",:all_pageids=>nil).each do |p| Page.where(:bind_model=>"SeminarMain",:all_pageids=>nil).each do |p|
p.save p.save
end end
tmp_flags = s.tmp_flags Site.update_all("$push"=>{"tmp_flags"=>'fix_sr'})
tmp_flags << 'fix_sr'
Site.update_all(:tmp_flags => tmp_flags)
end end
if need_update2 if need_update2
SeminarMain.where(:enable_recaptcha=>nil).each do |seminar_main| SeminarMain.where(:enable_recaptcha=>nil).each do |seminar_main|
seminar_main.update_enable_recaptcha seminar_main.update_enable_recaptcha
end end
if update_flag if update_flag
s = Site.first Site.update_all("$push"=>{"tmp_flags"=>'smer1'})
s.tmp_flags << 'smer1' end
s.save end
if need_update3
SeminarMain.all.to_a.each do |seminar_main|
seminar_main.migrate_old
end
if update_flag
Site.update_all("$push"=>{"tmp_flags"=>'smer2'})
end end
end end
end end