Browse Source

竞赛配置子赛项

pull/313/head
xiaoxiaoqiong 4 years ago
parent
commit
f60cd409b6
3 changed files with 15 additions and 3 deletions
  1. +10
    -0
      app/controllers/settings_controller.rb
  2. +1
    -1
      app/models/site.rb
  3. +4
    -2
      app/views/settings/show.json.jbuilder

+ 10
- 0
app/controllers/settings_controller.rb 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|


+ 1
- 1
app/models/site.rb 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? }


+ 4
- 2
app/views/settings/show.json.jbuilder 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

Loading…
Cancel
Save