From a8375466208aa764a948c73d990cde4e87070ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Mon, 19 Dec 2022 12:20:03 +0800 Subject: [PATCH] Fix bug. --- app/controllers/admin/seminars_controller.rb | 2 ++ app/models/seminar_template_setting.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index 84560af..837d2b0 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -81,6 +81,8 @@ class Admin::SeminarsController < OrbitAdminController available_locales = available_locales.map{|l| l.to_s} if @seminar_page_root.nil? @seminar_page_root = @seminar_template_setting.create_seminar_pages + else + @seminar_template_setting.create_seminar_pages(false) end @items = @seminar_page_root.child_page @parent_pages = [] diff --git a/app/models/seminar_template_setting.rb b/app/models/seminar_template_setting.rb index 725c845..56bbeb5 100644 --- a/app/models/seminar_template_setting.rb +++ b/app/models/seminar_template_setting.rb @@ -51,7 +51,7 @@ class SeminarTemplateSetting end end end - def create_seminar_pages + def create_seminar_pages(force_update=true) if self.seminar_main @seminar = self.seminar_main @seminar_page_root = Page.where(:parent_page_id=>self.seminar_main_id).first @@ -60,7 +60,7 @@ class SeminarTemplateSetting if @seminar_page_root.nil? @seminar_page_root = Page.create(:parent_page_id=>self.seminar_main_id,:module=>"seminars_home",:name_translations=>@seminar.title_translations,:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales) else - @seminar_page_root.update(:name_translations=>@seminar.title_translations,:module=>"seminars_home",:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales) + @seminar_page_root.update(:name_translations=>@seminar.title_translations,:module=>"seminars_home",:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales) if force_update end pages_info = PagesInfo relation_model = {"news" => "CustomBulletin","album"=>"CustomAlbum"} @@ -79,7 +79,7 @@ class SeminarTemplateSetting 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) else - seminar_page.update(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:module=>page_module) + seminar_page.update(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:module=>page_module) if force_update end end return @seminar_page_root