forked from Trustie/forgeplus
管理员新字段
This commit is contained in:
parent
8115858c47
commit
50db13a7ef
|
|
@ -221,7 +221,7 @@ class CompetitionInfosController < ApplicationController
|
|||
|
||||
def competition_info_params
|
||||
params.require(:competition_info).permit(:title, :zones, :zones_local, :sub_competitions, :identifier, :content,
|
||||
:video_url, :is_local, :manager_ids, :upload_date, :enroll_date, :guide, :about_us, :banner_url, :enroll_template)
|
||||
:video_url, :is_local, :manager_ids, :upload_date, :enroll_date, :guide, :about_us, :banner_url, :enroll_template, :admin_data)
|
||||
end
|
||||
|
||||
def find_competition
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
class CompetitionInfo < ApplicationRecord
|
||||
has_many :competition_users
|
||||
|
||||
serialize :admin_data, JSON
|
||||
|
||||
def competition_zones
|
||||
self.is_local? ? self.zones_local.to_s.split(",") : self.zones.to_s.split(",")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,4 +6,7 @@ json.data do
|
|||
json.sub_competitions @competition_info.sub_competitions.to_s.split(",")
|
||||
json.is_manager @competition_info.is_manager?(current_user)
|
||||
json.manager_zones @competition_info.manager_zones(current_user)
|
||||
if current_user.admin?
|
||||
json.admin_data @competition_info.admin_data
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
# 单表存储的信息可以放里面
|
||||
json.array! users do |user|
|
||||
json.username user.full_name
|
||||
json.login user.login
|
||||
json.user_id user.id
|
||||
json.image_url url_to_avatar(user)
|
||||
json.profile_completed user.profile_completed
|
||||
end
|
||||
|
||||
# 单表存储的信息可以放里面
|
||||
json.array! users do |user|
|
||||
json.username user.full_name
|
||||
json.login user.login
|
||||
json.phone user.phone
|
||||
json.user_id user.id
|
||||
json.image_url url_to_avatar(user)
|
||||
json.profile_completed user.profile_completed
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddCompetitionInfoAdmin < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :competition_infos, :admin_data, :text
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue