fix bug. #6

Merged
chiu merged 2 commits from 123/seminar:master into master 2023-03-07 13:40:24 +00:00
2 changed files with 17 additions and 12 deletions
Showing only changes of commit 3a59df9efb - Show all commits

View File

@ -186,7 +186,12 @@ class SeminarMain
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
@triggered_initialize = true
save_flag = false
@ -234,11 +239,6 @@ class SeminarMain
self.save(:validate=>false) if save_flag
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)
@enable_custom_template = self.enable_custom_template
if call_action.nil?

View File

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