From 511fffa0e2bce7cfa77ee0ff46700ffe3447ab39 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Wed, 12 Apr 2023 12:35:21 +0800 Subject: [PATCH] Fix bug. --- app/models/seminar_main.rb | 8 ++++---- app/models/seminar_template_setting.rb | 4 ++-- config/routes.rb | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index afc4886..369aaf6 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -333,7 +333,7 @@ class SeminarMain page_part.sub_parts.where(kind: "module_widget",module: "custom_announcement").destroy end self.annc_count = 0 - home_page.find_page(:page_id=>"news").update_all(:enabled_for=>[],:enabled_for_mobile=>[],:menu_enabled_for => []) + home_page.find_page(:page_id=>"news").update_all(:enabled_for=>[],:enabled_for_mobile=>false,:menu_enabled_for => []) else if page_part.nil? page_part = home_page.page_parts.create(:part_id=>annc_part_id) @@ -345,7 +345,7 @@ class SeminarMain data_count: annc_data_count,custom_data_field: {"bind_module_app"=>"seminar", "bind_uid"=>self.uid}) sub_part.select_options.create(annc_default_select_option_attr) end - home_page.find_page(:page_id=>"news").update_all(:enabled_for=>@@in_use_locales,:enabled_for_mobile=>@@in_use_locales,:menu_enabled_for => @@in_use_locales) + home_page.find_page(:page_id=>"news").update_all(:enabled_for=>@@in_use_locales,:enabled_for_mobile=>true,:menu_enabled_for => @@in_use_locales) end self.save end @@ -378,7 +378,7 @@ class SeminarMain if page_part page_part.sub_parts.where(kind: "module_widget",module: "custom_gallery").destroy end - home_page.find_page(:page_id=>"album").update_all(:enabled_for=>[],:enabled_for_mobile=>[],:menu_enabled_for => []) + home_page.find_page(:page_id=>"album").update_all(:enabled_for=>[],:enabled_for_mobile=>false,:menu_enabled_for => []) self.annc_count = 0 else if page_part.nil? @@ -390,7 +390,7 @@ class SeminarMain widget_type: "custom_gallery_widget2",widget_method: "widget", data_count: album_data_count,custom_data_field: {"bind_module_app"=>"seminar", "bind_uid"=>self.uid}) end - home_page.find_page(:page_id=>"album").update_all(:enabled_for=>@@in_use_locales,:enabled_for_mobile=>@@in_use_locales,:menu_enabled_for => @@in_use_locales) + home_page.find_page(:page_id=>"album").update_all(:enabled_for=>@@in_use_locales,:enabled_for_mobile=>true,:menu_enabled_for => @@in_use_locales) end self.save end diff --git a/app/models/seminar_template_setting.rb b/app/models/seminar_template_setting.rb index c9ed1a2..189a229 100644 --- a/app/models/seminar_template_setting.rb +++ b/app/models/seminar_template_setting.rb @@ -80,9 +80,9 @@ class SeminarTemplateSetting end end if seminar_page.nil? - seminar_page = @seminar_page_root.child_page.create(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:enabled_for=>available_locales_tmp,:module=>page_module,:menu_enabled_for=>available_locales_tmp) + seminar_page = @seminar_page_root.child_page.create(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:enabled_for=>available_locales_tmp,:module=>page_module,:menu_enabled_for=>available_locales_tmp,:enabled_for_mobile=>true) else - seminar_page.update(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:module=>page_module) if force_update + seminar_page.update(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:module=>page_module,:enabled_for_mobile=>true) if force_update end end return @seminar_page_root diff --git a/config/routes.rb b/config/routes.rb index 75ef0b5..0fc54f5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ Rails.application.routes.draw do 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')) + need_update4 = !update_flag || !(s.tmp_flags.include?('smer3')) if need_update1 Page.where(:bind_model=>"SeminarMain",:all_pageids=>nil).each do |p| p.save @@ -32,6 +33,21 @@ Rails.application.routes.draw do Site.update_all("$push"=>{"tmp_flags"=>'smer2'}) end end + if need_update4 + in_use_locales = s.in_use_locales.map(&:to_s) + Page.where(:parent_page_id.in=>SeminarMain.pluck(:id)).update_all(:enabled_for_mobile=>true, :menu_enabled_for=>in_use_locales, :enabled_for=>in_use_locales) + Page.where(:parent_page_id.in=>SeminarMain.pluck(:id)).each do |p| + p.find_page.each do |pp| + if pp[:enabled_for_mobile].class == Array + pp.enabled_for_mobile = pp[:enabled_for_mobile].present? + pp.save + end + end + end + if update_flag + Site.update_all("$push"=>{"tmp_flags"=>'smer3'}) + end + end end SeminarSignupField.create_indexes SeminarSubmissionField.create_indexes