This commit is contained in:
BoHung Chiu 2022-04-18 21:45:34 +08:00
parent 542c6a06aa
commit 908a90d467
3 changed files with 23 additions and 2 deletions

View File

@ -380,6 +380,9 @@ class Admin::RulingTimersController < OrbitMemberController
end end
def set_setting def set_setting
@module_app = ModuleApp.where(:key=>@app_title).first @module_app = ModuleApp.where(:key=>@app_title).first
if @module_app.nil?
@module_app = OrbitMemberModule.where(:key=>@app_title).first
end
@setting = RulingTimerSetting.first @setting = RulingTimerSetting.first
if @setting.nil? if @setting.nil?
@setting = RulingTimerSetting.create @setting = RulingTimerSetting.create

View File

@ -13,6 +13,23 @@ Rails.application.routes.draw do
end end
s.save if save_flag s.save if save_flag
@module_app = ModuleApp.where(:key=>"ruling_timer").first @module_app = ModuleApp.where(:key=>"ruling_timer").first
if @module_app.nil?
@module_app = OrbitMemberModule.where(:key=>"ruling_timer").first
else
@new_module_app = OrbitMemberModule.where(:key=>"ruling_timer").first
@module_app.categories.each do |c|
c.module_app = nil
c.orbit_member_module = @new_module_app
c.save
end
@module_app.tags.each do |c|
c.module_app = []
c.orbit_member_module = [@new_module_app]
c.save
end
@module_app.destroy
@module_app = @new_module_app
end
if @module_app.categories.count == 0 if @module_app.categories.count == 0
category = @module_app.categories.new category = @module_app.categories.new
category.title_translations = I18n.available_locales.map{|l| [l.to_s,I18n.with_locale(l){I18n.t("ruling_timer.personal_project")}]}.to_h category.title_translations = I18n.available_locales.map{|l| [l.to_s,I18n.with_locale(l){I18n.t("ruling_timer.personal_project")}]}.to_h

View File

@ -2,6 +2,7 @@ module RulingTimer
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "ruling_timer" do initializer "ruling_timer" do
begin begin
puts "ruling_timerruling_timerruling_timer"
OrbitApp.registration "RulingTimer", :type => "OrbitMemberModule" do OrbitApp.registration "RulingTimer", :type => "OrbitMemberModule" do
module_label "ruling_timer.ruling_timer" module_label "ruling_timer.ruling_timer"
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
@ -35,14 +36,14 @@ module RulingTimer
:available_for => 'managers' :available_for => 'managers'
context_link 'categories', context_link 'categories',
:link_path=>"admin_module_app_categories_path" , :link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ruling_timer').id}", :link_arg=>"{:module_app_id=>OrbitMemberModule.find_by(:key=>'ruling_timer').id,:module_app_type=>'orbit_member_module'}",
:priority=>4, :priority=>4,
:active_for_action=>{'admin/ruling_timers'=>'categories'}, :active_for_action=>{'admin/ruling_timers'=>'categories'},
:active_for_category => 'RulingTimer', :active_for_category => 'RulingTimer',
:available_for => 'managers' :available_for => 'managers'
context_link 'tags', context_link 'tags',
:link_path=>"admin_module_app_tags_path" , :link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ruling_timer').id}", :link_arg=>"{:module_app_id=>OrbitMemberModule.find_by(:key=>'ruling_timer').id,:module_app_type=>'orbit_member_module'}",
:priority=>5, :priority=>5,
:active_for_action=>{'admin/ruling_timers'=>'tags'}, :active_for_action=>{'admin/ruling_timers'=>'tags'},
:active_for_tag => 'RulingTimer', :active_for_tag => 'RulingTimer',