竞赛配置子赛项

This commit is contained in:
xiaoxiaoqiong 2022-04-08 18:40:52 +08:00
parent 9d46f2743d
commit f60cd409b6
3 changed files with 15 additions and 3 deletions

View File

@ -4,6 +4,7 @@ class SettingsController < ApplicationController
get_navbar
get_add_menu
get_common_menu
get_sub_competitions
get_personal_menu
get_third_party
get_top_system_notification
@ -29,6 +30,15 @@ class SettingsController < ApplicationController
end
end
def get_sub_competitions
@sub_competitions = []
Site.add.pluck(:key).each do |key|
hash = {}
hash.merge!("#{key.to_s}": Site.add.where(key: key).select(:id, :name, :url, :key).to_a.map(&:serializable_hash))
@sub_competitions << hash
end
end
def get_common_menu
@common = {}
Site.common.select(:url, :key).each do |site|

View File

@ -15,7 +15,7 @@ class Site < ApplicationRecord
# add: 添加类链接
# personal: 个人名下类链接,
# common: 普通链接
enum site_type: { add: 0, personal: 1, common: 2 }
enum site_type: { add: 0, personal: 1, common: 2, competition: 3 }
scope :by_search, -> (keyword){ where("name LIKE :keyword OR url LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? }
scope :by_site_type, -> (site_type){ where(site_type: strip_param(site_type)) unless strip_param(site_type).blank? }

View File

@ -51,6 +51,10 @@ json.setting do
json.array! @add
end
json.sub_competitions do
json.array! @sub_competitions
end
json.personal do
json.array! @personal
end
@ -66,6 +70,4 @@ json.setting do
else
json.system_notification nil
end
json.sub_competitions EduSetting.get("sub_competitions")
end