Merge branch 'dev_osredm_server' of https://gitlink.org.cn/Trustie/forgeplus into dev_osredm_server

This commit is contained in:
yystopf 2025-05-19 10:51:04 +08:00
commit efa9572fee
37 changed files with 1077 additions and 14 deletions

View File

@ -23,7 +23,7 @@ class Admins::LaboratorySettingsController < Admins::BaseController
def form_params
params.permit(:identifier, :name,
:nav_logo, :login_logo, :tab_logo, :oj_banner,
:nav_logo, :login_logo, :tab_logo, :oj_banner, :index_logo,
:subject_banner, :course_banner, :competition_banner, :moop_cases_banner,
:footer, navbar: %i[name link hidden index])
end

View File

@ -0,0 +1,76 @@
class Admins::TopicsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_topic, only: [:edit, :update, :destroy, :show]
def index
scope = ::Topic.with_mutil_type(params[:topic_type])
scope = scope.where(location: params[:location]) if params[:location].present?
scope = scope.where(type: params[:type]) if params[:type].present?
scope = scope.ransack(title_cont: params[:search])
topics = scope.result(distinct: true)
@topics = paginate(topics)
end
def new
@topic = ::Topic.new
end
def create
@topic = topic_model.new(topic_params)
params[:topic_type] = @topic.type_group_name
if @topic.save
save_image_file(params[:image], @topic) if params[:image].present?
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:success] = "新增成功"
else
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:danger] = "新增失败"
end
end
def show
end
def edit
end
def update
@topic.attributes = topic_params
if @topic.save!
save_image_file(params[:image], @topic) if params[:image].present?
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:success] = "更新成功"
return
else
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:danger] = "更新失败"
return
end
end
def destroy
if @topic.destroy
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:success] = "删除成功"
else
redirect_to admins_topics_path(topic_type: params[:topic_type])
flash[:danger] = "删除失败"
end
end
private
def find_topic
@topic = topic_model.find(params[:id])
params[:topic_type] = @topic.type_group_name
end
def topic_model
::Topic
end
def topic_params
params.require(:topic).permit(:type, :title, :uuid, :url, :order_index,
:location, :identifier, :labels, :description, :date)
end
end

View File

@ -136,6 +136,14 @@ class CompetitionInfosController < ApplicationController
end
if params[:apply_status].present?
competition_users = competition_users.where(ext3: params[:apply_status].to_s.split(","))
else
if ["yys2025", "tzb2025"].include?(@competition_info.identifier)
if params[:type]=="un_file"
competition_users = competition_users.where("leader is not null and phone is not null and org_name is not null")
else
competition_users = competition_users.where("competition_users.enroll_template_id is not null")
end
end
end
if params[:upload].to_s == "true"
# competition_users = competition_users.joins("join attachments on attachments.container_type='CompetitionUser' and attachments.container_id = competition_users.id")
@ -159,7 +167,7 @@ class CompetitionInfosController < ApplicationController
enroll_fields = @competition_info.enroll_fields
enroll_fields = enroll_fields.delete_if { |key, value| ["sub_item", "works_name", "works_url"].include?(value) } if params[:upload].to_s != "true"
@table_columns = enroll_fields.keys
@table_columns = @table_columns + %w(参赛报名表下载链接)
# @table_columns = @table_columns + %w(参赛报名表下载链接)
@table_columns = @table_columns + %w(作品下载链接) if params[:upload].to_s == "true" && !enroll_fields.values.include?("works_url")
@table_columns = @table_columns + %w(申请表下载链接) if params[:apply_status].present?
@table_columns = @table_columns + %w(bm审查下载链接) if @competition_info.identifier == "KXSYSJ-2024" && params[:upload].to_s == "true"
@ -171,8 +179,8 @@ class CompetitionInfosController < ApplicationController
competition_users.each do |u|
info_array = []
file_array = []
file = Attachment.where_id_or_uuid(u.enroll_template_id).first
file_array = file_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"]
# file = Attachment.where_id_or_uuid(u.enroll_template_id).first
# file_array = file_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"]
if params[:upload].to_s == "true" && !enroll_fields.values.include?("works_url")
file_array = file_array + [u.attachments.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(u.attachments.first)}"]
end
@ -321,6 +329,7 @@ class CompetitionInfosController < ApplicationController
competition_user.members = params[:members]
competition_user.status = 1
competition_user.status = 2 if @competition_info.identifier.include?("qz202")
competition_user.status = 2 if @competition_info.identifier.include?("tzb2025")
competition_user.save
render_ok
end
@ -332,6 +341,7 @@ class CompetitionInfosController < ApplicationController
competition_user.members = params[:members]
competition_user.status = 1
competition_user.status = 2 if @competition_info.identifier.include?("qz202")
competition_user.status = 2 if @competition_info.identifier.include?("tzb2025")
competition_user.save
render_ok
end
@ -346,7 +356,16 @@ class CompetitionInfosController < ApplicationController
def upload_apply_template
competition_user = CompetitionUser.find_by(competition_info: @competition_info.id, user_id: current_user.id)
tip_exception "未报名,请先报名" if competition_user.blank?
# tip_exception "未报名,请先报名" if competition_user.blank?
if competition_user.blank? && ["yys2025", "tzb2025"].include?(@competition_info.identifier)
competition_user = CompetitionUser.new
competition_user.competition_info = @competition_info
competition_user.user = current_user
competition_user.status = 2
competition_user.save
else
tip_exception "未报名,请先报名" unless competition_user.present?
end
tip_exception "附件参数apply_template_id不能为空" if params[:apply_template_id].blank?
competition_user.update_attributes!(ext2: params[:apply_template_id], ext3: 1)
render_ok
@ -481,6 +500,18 @@ class CompetitionInfosController < ApplicationController
end
end
def tzb_actived
tip_exception "请输入激活码" if params[:code].blank?
SyncCompetitionTzbUserJob.perform_later("code")
tzb_user = CompetitionTzbUser.find_by(activation_code: params[:code])
tip_exception "激活码正在同步确认中,请稍后再试" if tzb_user.blank?
tip_exception "激活码正在同步确认中,请稍后再试" if tzb_user.user_id.blank?
user = User.find_by(id: tzb_user.user_id)
successful_authentication(user)
tzb_user.update_attributes!(actived: true)
render_ok({ user: { login: user.login, mail: user.mail, password: tzb_user.pwd } })
end
def destroy
if @competition_info.destroy!
flash[:success] = '删除成功'

View File

@ -0,0 +1,69 @@
class SyncCompetitionTzbUserJob < ApplicationJob
queue_as :default
def perform(code=nil)
url = EduSetting.get("SyncCompetitionTzbUserUrl") || "https://2025.tiaozhanbei.net/api/v1/ai_contest/3579510184/project_list/"
uri = URI.parse(url)
http = Net::HTTP.new(uri.hostname, uri.port)
if uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = true
end
response = http.send_request('GET', uri.path, nil, {'Content-Type' => 'application/json','Authorization' => 'Bearer sk-CQ5oe9UI14nlwYnMtsNV4MBMDLwQ67bQXIa2fDy5m0bSQ5Ts'})
# Rails.logger.info("SyncCompetitionTzbUserJob body===#{response.body}")
result = JSON.parse(response.body)
# data = '{"Code":"Ok","Message":"成功","Data":[{"corp_id":123456,"match_id":666,"user_uid":"uid_y0gqNR3EesqZVgA",
# "project_pid":"pid_123001","activation_code":"V2nyoEYzl2zRaVySpldc","project_status":"not_finished",
# "project_status_text":"未提交","status_level":"school","status_level_text":"校级","school_code":"10003",
# "school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_JHnTBdt8GA3tziq","project_pid":"pid_123002","activation_code":"nde8u5HNQ7qqXjkBIQG0","project_status":"submit_to","project_status_text":"已提交","status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_2tCNcoKX8T8oHvk","project_pid":"pid_123003","activation_code":"iZQCh3mfuJ8ESrUPwGRo","project_status":"pass_by","project_status_text":"审核通过","status_level":"school","status_level_text":"校级","school_code":"10001","school_name":"北京大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_DziaXaNTkyS1M05","project_pid":"pid_123004","activation_code":"c42BKyehYWAxeAqjLdc8","project_status":"not_pass_by","project_status_text":"审核未通过","status_level":"province","status_level_text":"省级","school_code":"10001","school_name":"北京大学","province_name":"北京"}]}'
# result = JSON.parse(data)
Rails.logger.info("SyncCompetitionTzbUserJob size===#{result["Data"].size}")
result["Data"].each do |row|
tzb_user = CompetitionTzbUser.find_by(user_uid: row["user_uid"])
if tzb_user.blank?
tzb_user = CompetitionTzbUser.new
tzb_user.user_uid = row["user_uid"]
tzb_user.user_email = row["user_email"]
tzb_user.activation_code = row["activation_code"]
tzb_user.info_json = row.to_json
tzb_user.save
end
if tzb_user.present? && tzb_user.user_id.blank?
password = generate_user_login('')
user_id = register_user(tzb_user, password)
tzb_user.update_attributes!(user_id: user_id, pwd: password)
end
end
end
def register_user(tzb_user, pwd)
user = User.find_by(mail: tzb_user.user_email)
return user.id if user.present?
username = generate_user_login('p')
email = tzb_user.user_email
email = "#{username}@example.org" if email.blank?
company_name = tzb_user.user_info("school_name")
user_type = company_name.present? && company_name.include?("大学") ? 4 : 6
password = pwd
user = User.new(login: username, mail: email, password: password, type: 'User', company_name: company_name)
interactor = Gitea::RegisterInteractor.call({ username: username, email: email, password: password })
gitea_user = interactor.result
result = Gitea::User::GenerateTokenService.call(username, password)
user.gitea_token = result['sha1']
user.gitea_uid = gitea_user[:body]['id']
user.user_type = user_type
user.save!
UserExtension.create!(user_id: user.id)
user.id
end
# 生成邀请码
def generate_user_login type
code = %W(0 1 2 3 4 5 6 7 8 9).sample(8).join
code = type + code.to_s
return generate_user_login(type) if User.where(login: code).present?
code
end
end

View File

@ -15,6 +15,7 @@ module Util::FileManage
end
def source_disk_filename(source, suffix=nil)
Rails.logger.info "11111111111=========+#{source.class.name}"
disk_filename(source.class.name, source.id, suffix)
end

View File

@ -0,0 +1,12 @@
class CompetitionTzbUser < ApplicationRecord
def user_info(attr)
return "" if self.info_json.blank?
data = JSON.parse(self.info_json)
data["#{attr}"]
rescue => err
Rails.logger.info("info_json is not json,error:#{err}")
""
end
end

View File

@ -35,6 +35,10 @@ class LaboratorySetting < ApplicationRecord
image_url('nav')
end
def index_logo_url
image_url('index')
end
def tab_logo_url
image_url('tab')
end

View File

@ -18,6 +18,105 @@ class Topic < ApplicationRecord
default_scope { order(order_index: :desc)}
scope :with_single_type, ->(type){where(type: trans_simpletype_to_classtype(type))}
scope :with_mutil_type, ->(type){where(type: group_class_type_names(type))}
# self.inheritance_column = nil
def self.has_templates?(type)
type_simple_name = Topic.type_simple_name(type)
["ck_case", "scientific_organization"].include?(type_simple_name)
end
def self.base_types
[
# ["forums", "Topic::ActivityForum", "首页平台动态"],
# ["forums", "Topic::ExcellentProject", "首页优秀项目"],
# ["forums", "Topic::ExperienceForum", "首页经验分享"],
# ["forums", "Topic::TechnicalDiscussion", "首页技术讨论"],
# ["forums", "Topic::PinnedForum", "首页精选文章"],
# ["forums", "Topic::CkForum", "创客首页-创客内容"],
# ["forums", "Topic::JsForum", "创客首页-竞赛内容"],
# ["forums", "Topic::GlccNews", "GLCC新闻稿"],
["forums", "Topic::JoinUs", "底部加入我们"],
["banners", "Topic::Banner", "首页banner"],
["banners", "Topic::Card", "开源首页卡片"],
["banners", "Topic::CkBanner", "创客空间卡片"],
["banners", "Topic::AppletBanner", "小程序首页banner"],
# ["logos", "Topic::Cooperator", "首页合作伙伴"],
["logos", "Topic::Organization", "项目首页组织logo"],
["logos", "Topic::ScientificOrganization", "首页/友情链接-科研机构logo"],
["logos", "Topic::School", "首页/友情链接-高校logo"],
# ["logos", "Topic::FriendlyLink", "首页友情链接-科研机构logo"],
["others", "Topic::ServiceTerm", "服务条款"],
]
end
def self.group_class_types(type)
Topic.base_types.select { |s| s[0] == type }
end
def self.group_class_type_names(type)
Topic.group_class_types(type).map{|s| s[1]}
end
def self.group_types_options(type)
Topic.group_class_types(type).map{|s| [s[2],s[1]]}
end
def self.sub_types
[
["Topic::ActivityForum", "activity_forum", "首页平台动态"],
["Topic::Banner", "banner", "首页banner"],
["Topic::Card", "card", "首页卡片内容"],
["Topic::Cooperator", "cooperator", "首页合作伙伴"],
["Topic::Organization", "organization", "首页组织logo"],
["Topic::ScientificOrganization", "scientific_organization", "科研机构logo"],
["Topic::School", "school", "首页高校logo"],
["Topic::ExcellentProject", "excellent_project", "首页优秀项目"],
["Topic::ExperienceForum", "experience_forum", "首页经验分享"],
["Topic::GlccNews", "glcc_news", "GLCC新闻稿"],
["Topic::PinnedForum", "pinned_forum", "首页精选文章"],
["Topic::AppletBanner", "applet_banner", "Applet首页banner"],
["Topic::FriendlyLink", "friendly_link", "底部友情链接"],
["Topic::JoinUs", "Join_us", "底部加入我们"],
["Topic::CkBanner", "ck_banner", "创客空间卡片内容"],
["Topic::TechnicalDiscussion", "technical_discussion", "首页技术讨论"],
["Topic::CkForum", "ck_forum", "创客首页-创客内容"],
["Topic::JsForum", "js_forum", "创客首页-竞赛内容"],
["Topic::ServiceTerm", "service_term", "服务条款"],
["Topic::CkCase", "ck_case", "创客案例"],
]
end
def self.opt_select
Topic.sub_types.map{|s| [s[2],s[0]]}
end
def type_cn_name
filter = Topic.base_types.select { |s| s[1] == self.type }
filter.blank? ? self.type : filter.first[2]
end
def self.type_simple_name(type)
filter = Topic.sub_types.select { |s| s[0] == type }
filter.blank? ? type : filter.first[1]
end
def self.type_filter_cn_name(type)
filter = Topic.sub_types.select { |s| s[0] == type }
filter.blank? ? type : filter.first[2]
end
def type_group_name
filter = Topic.base_types.select { |s| s[1] == self.type }
filter.blank? ? self.type : filter.first[0]
end
def image
image_url('image')
@ -59,6 +158,12 @@ class Topic < ApplicationRecord
['Topic::CkForum', 'Topic::JsForum']
when 'service_term'
'Topic::ServiceTerm'
when 'scientific_organization'
'Topic::ScientificOrganization'
when 'ck_case'
'Topic::CkCase'
else
type
end
end

View File

@ -11,6 +11,6 @@
# location :integer default("0")
#
# Applet首页banner
# 创客首页-创客内容
class Topic::CkForum < Topic
end

View File

@ -11,6 +11,6 @@
# location :integer default("0")
#
# Applet首页banner
# 创客首页-竞赛内容
class Topic::JsForum < Topic
end

View File

@ -0,0 +1,3 @@
# 科研机构
class Topic::ScientificOrganization < Topic
end

View File

@ -11,6 +11,6 @@
# location :integer default("0")
#
# 首页组织logo
# 服务条款
class Topic::ServiceTerm < Topic
end

View File

@ -40,6 +40,7 @@ class Admins::SaveLaboratorySettingService < ApplicationService
save_image_file(params[:nav_logo], 'nav')
save_image_file(params[:login_logo], 'login')
save_image_file(params[:tab_logo], 'tab')
save_image_file(params[:index_logo], 'index')
save_image_file(params[:subject_banner], '_subject_banner')
save_image_file(params[:course_banner], '_course_banner')
save_image_file(params[:competition_banner], '_competition_banner')

View File

@ -46,7 +46,20 @@
<div class="setting-item-head"><h6>Logo设置</h6></div>
<div class="dropdown-divider"></div>
<div class="pl-0 py-3 row setting-item-body">
<div class="col-12 col-md-4 logo-item">
<div class="col-12 col-md-3 logo-item">
<% nav_logo_img = setting.index_logo_url %>
<div class="logo-item-left mr-3 <%= nav_logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= nav_logo_img %>" style="<%= nav_logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:index_logo, accept: 'image/png,image/jpg,image/jpeg', style: 'display: none', value: params[:index_logo]) %>
<label for="index_logo" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<div class="logo-item-right">
<div class="logo-item-title flex-1">网站首页logo</div>
<div>格式PNG、JPG</div>
<div>尺寸高度38px以内宽等比例缩放</div>
</div>
</div>
<div class="col-12 col-md-3 logo-item">
<% nav_logo_img = setting.nav_logo_url %>
<div class="logo-item-left mr-3 <%= nav_logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= nav_logo_img %>" style="<%= nav_logo_img.present? ? '' : 'display: none' %>"/>
@ -60,7 +73,7 @@
</div>
</div>
<div class="col-12 col-md-4 logo-item">
<div class="col-12 col-md-3 logo-item">
<% login_logo_img = setting.login_logo_url %>
<div class="logo-item-left mr-3 <%= login_logo_img ? 'has-img' : '' %>">
<img class="logo-item-img login-logo-img" src="<%= login_logo_img %>" style="<%= login_logo_img.present? ? '' : 'display: none' %>"/>
@ -74,7 +87,7 @@
</div>
</div>
<div class="col-12 col-md-4 logo-item">
<div class="col-12 col-md-3 logo-item">
<% tab_logo_img = setting.tab_logo_url %>
<div class="logo-item-left mr-3 <%= tab_logo_img ? 'has-img' : '' %>">
<img class="logo-item-img tab-logo-img" src="<%= tab_logo_img %>" style="<%= tab_logo_img.present? ? '' : 'display: none' %>"/>

View File

@ -0,0 +1,91 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.hidden_field :type, value: @type %>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
跳转地址 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :url, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
帖子ID <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :uuid, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
显示位置
</label>
<% location_options = [['', ''], ['首页', 'home'], ['竞赛', 'competition'], ['底部', 'footer']] %>
<%= select_tag('topic_applet_banner[location]', options_for_select(location_options), class: 'form-control') %>
</div>
<div class="form-group">
<label>
描述 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_area :description, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
竞赛标识/创客ID <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :identifier, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
标签 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :labels, class: "form-control input-lg", required: true %>
</div>
<div class="logo-item">
<% logo_img = @topic.image %>
<% if logo_img.present? %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% else %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', required: true, style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% end %>
<div class="logo-item-right">
<div class="logo-item-title flex-1">logo<span class="ml10 color-orange mr20">*</span></div>
<div>格式PNG、JPG</div>
<div>尺寸高度38px以内宽等比例缩放</div>
</div>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,72 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label for="type">配置类型:</label>
<% user_type_options = Topic.group_types_options(params[:topic_type]) %>
<%= select_tag('topic[type]', options_for_select(user_type_options, @topic.type), class: 'form-control') %>
</div>
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<input type="hidden" name="topic_type" , value="<%= params[:topic_type] %>"/>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
跳转地址 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :url, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
显示位置
</label>
<% location_options = [['', ''], ['首页', 'home'], ['竞赛', 'competition'], ['底部', 'footer']] %>
<%= select_tag('topic[location]', options_for_select(location_options, @topic.location), class: 'form-control') %>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
<div class="logo-item">
<% logo_img = @topic.image %>
<% if logo_img.present? %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% else %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', required: true, style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% end %>
<div class="logo-item-right">
<div class="logo-item-title flex-1">logo<span class="ml10 color-orange mr20">*</span></div>
<div>格式PNG、JPG</div>
<div>尺寸高度38px以内宽等比例缩放</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,57 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label>
领域 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :labels, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.hidden_field :type, value: @type %>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
id <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :uuid, class: "form-control", required: true %>
</div>
<div class="form-group">
<label>
描述 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_area :description, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
金额 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :identifier, class: "form-control", placeholder: "" , required: true %>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,51 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label for="type">配置类型:</label>
<% user_type_options = Topic.group_types_options(params[:topic_type]) %>
<%= select_tag('topic[type]', options_for_select(user_type_options, @topic.type), class: 'form-control') %>
</div>
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<input type="hidden" name="topic_type" , value="<%= params[:topic_type] %>"/>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
帖子ID <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :uuid, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
描述 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_area :description, class: "form-control input-lg",required: true%>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,72 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label for="type">配置类型:</label>
<% user_type_options = Topic.group_types_options(params[:topic_type]) %>
<%= select_tag('topic[type]', options_for_select(user_type_options, @topic.type), class: 'form-control') %>
</div>
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<input type="hidden" name="topic_type" , value="<%= params[:topic_type] %>"/>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
跳转地址 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :url, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
显示位置
</label>
<% location_options = [['', ''], ['首页', 'home'], ['竞赛', 'competition'], ['底部', 'footer']] %>
<%= select_tag('topic[location]', options_for_select(location_options, @topic.location), class: 'form-control') %>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
<div class="logo-item">
<% logo_img = @topic.image %>
<% if logo_img.present? %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% else %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', required: true, style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% end %>
<div class="logo-item-right">
<div class="logo-item-title flex-1">logo<span class="ml10 color-orange mr20">*</span></div>
<div>格式PNG、JPG</div>
<div>尺寸高度38px以内宽等比例缩放</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,60 @@
<div class="modal fade activity-forum-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增-#{Topic.type_filter_cn_name(@type)}" : "编辑-#{Topic.type_filter_cn_name(@type)}" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @topic, url: { controller: "topics", action: "#{type}" }, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<div class="form-group">
<label>
标题 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.hidden_field :type, value: @type %>
<%= p.text_field :title, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
跳转地址 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :url, class: "form-control input-lg", required: true %>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control", placeholder: "" %>
</div>
<div class="logo-item">
<% logo_img = @topic.image %>
<% if logo_img.present? %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% else %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg', required: true, style: "opacity: 0", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<% end %>
<div class="logo-item-right">
<div class="logo-item-title flex-1">logo<span class="ml10 color-orange mr20">*</span></div>
<div>格式PNG、JPG</div>
<div>尺寸高度38px以内宽等比例缩放</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,47 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="20%">类型</th>
<th width="20%">标题</th>
<th width="20%">跳转地址</th>
<th width="10%">内容信息ID</th>
<th width="10%">显示位置</th>
<th width="20%">标识</th>
<th width="50%">标签</th>
<th width="0%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= topic.type_cn_name %></td>
<td><%= topic.title %></td>
<td><%= topic.url %></td>
<td><%= topic.uuid %></td>
<td><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %></td>
<td><%= topic.identifier %></td>
<td>
<% if topic.labels.present? %>
<% topic.labels.split(",").each do |label| %>
<span class="btn btn-primary btn-sm"><%= label %></span>
<% end %>
<% end %>
</td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,37 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="15%">类型</th>
<th width="20%">标题</th>
<th width="20%">跳转地址</th>
<th width="20%">图片</th>
<th width="10%">位置</th>
<th width="20%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= topic.type_cn_name %></td>
<td><%= topic.title %></td>
<td><%= topic.url %></td>
<td><img style="width:150px" src="<%= topic.image %>" /></td>
<td><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %></td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,39 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<!-- <th width="20%">类型</th>-->
<th width="20%">领域</th>
<th width="20%">标题</th>
<th width="20%">描述</th>
<th width="20%">id</th>
<th width="20%">金额</th>
<th width="20%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<!-- <td><%#= topic.type_cn_name %></td>-->
<td><%= topic.labels %></td>
<td><%= topic.title %></td>
<td><%= topic.description %></td>
<td><%= topic.uuid %></td>
<td><%= topic.identifier %></td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,35 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="15%">类型</th>
<th width="20%">标题</th>
<th width="20%">跳转地址</th>
<th width="10%">内容信息ID</th>
<th width="20%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= topic.type_cn_name %></td>
<td><%= topic.title %></td>
<td><%= topic.url %></td>
<td><%= topic.uuid %></td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,37 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="15%">类型</th>
<th width="20%">标题</th>
<th width="20%">跳转地址</th>
<th width="20%">图片</th>
<th width="10%">位置</th>
<th width="20%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= topic.type_cn_name %></td>
<td><%= topic.title %></td>
<td><%= topic.url %></td>
<td><img style="width:150px" src="<%= topic.image %>" /></td>
<td><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %></td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,35 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<!-- <th width="20%">类型</th>-->
<th width="20%">标题</th>
<th width="20%">跳转地址</th>
<th width="20%">图片</th>
<th width="20%">排序等级</th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if topics.present? %>
<% topics.each_with_index do |topic, index| %>
<tr class="activity-forum-item-<%= topic.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<!-- <td><%#= topic.type_cn_name %></td>-->
<td><%= topic.title %></td>
<td><%= topic.url %></td>
<td><img style="width:150px" src="<%= topic.image %>" /></td>
<td><%= topic.order_index %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %>
<%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %>

View File

@ -0,0 +1,23 @@
<%if params[:topic_type].present? %>
$("#activity-forum-modals").html("<%= j render(partial: "admins/topics/form_modal_#{params[:topic_type]}", locals: {type: 'update'}) %>")
<%else %>
$("#activity-forum-modals").html("<%= j render(partial: 'admins/topics/form_modal', locals: {type: 'update'}) %>")
<%end %>
$(".activity-forum-change-modal").modal('show');
$('.logo-item-left').on("change", 'input[type="file"]', function () {
var $fileInput = $(this);
var file = this.files[0];
var imageType = /image.*/;
if (file && file.type.match(imageType)) {
var reader = new FileReader();
reader.onload = function () {
var $box = $fileInput.parent();
$box.find('img').attr('src', reader.result).css('display', 'block');
$box.addClass('has-img');
};
reader.readAsDataURL(file);
} else {
}
});

View File

@ -0,0 +1,34 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb("#{Topic.type_filter_cn_name(@type)}") %>
<% end %>
<div class="box search-form-container project-list-form">
<%= form_tag(admins_topics_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %>
<!-- <input type="hidden" name="type", value="<%#=@type %>"/>-->
<input type="hidden" name="topic_type" , value="<%= params[:topic_type] %>"/>
<div class="form-group mr-2">
<label for="type">配置类型:</label>
<% user_type_options = [['全部', '']] | Topic.group_types_options(params[:topic_type]) %>
<%= select_tag(:type, options_for_select(user_type_options), class: 'form-control') %>
</div>
<div class="form-group mr-2">
<label for="location">显示位置:</label>
<% location_options = [['全部', ''], ['首页', 'home'], ['竞赛', 'competition'], ['底部', 'footer']] %>
<%= select_tag(:location, options_for_select(location_options), class: 'form-control') %>
</div>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_admins_topic_path(topic_type: params[:topic_type]), remote: true, class: "btn btn-primary pull-right", "data-disabled-with": "...新增" %>
</div>
<div class="box admin-list-container activity-forum-list-container">
<% if params[:topic_type].present? %>
<%= render partial: "admins/topics/list_#{params[:topic_type]}", locals: { topics: @topics } %>
<% else %>
<%= render partial: 'admins/topics/list', locals: { topics: @topics } %>
<% end %>
</div>
<div id="activity-forum-modals">
</div>

View File

@ -0,0 +1,5 @@
<%if params[:topic_type].present? %>
$('.activity-forum-list-container').html("<%= j( render partial: "admins/topics/list_#{params[:topic_type]}", locals: { topics: @topics } ) %>");
<%else %>
$('.activity-forum-list-container').html("<%= j( render partial: 'admins/topics/list', locals: { topics: @topics } ) %>");
<%end %>

View File

@ -0,0 +1,23 @@
<%if params[:topic_type].present? %>
$("#activity-forum-modals").html("<%= j render(partial: "admins/topics/form_modal_#{params[:topic_type]}", locals: {type: 'create'}) %>")
<%else %>
$("#activity-forum-modals").html("<%= j render(partial: 'admins/topics/form_modal', locals: {type: 'create'}) %>")
<%end %>
$(".activity-forum-change-modal").modal('show');
$('.logo-item-left').on("change", 'input[type="file"]', function () {
var $fileInput = $(this);
var file = this.files[0];
var imageType = /image.*/;
if (file && file.type.match(imageType)) {
var reader = new FileReader();
reader.onload = function () {
var $box = $fileInput.parent();
$box.find('img').attr('src', reader.result).css('display', 'block');
$box.addClass('has-img');
};
reader.readAsDataURL(file);
} else {
}
});

View File

@ -16,7 +16,7 @@ end
if trend.trend_type == "Issue"
json.partial! "issues/simple_issue_item", locals: {issue: trend.trend}
elsif trend.trend_type == "VersionRelease"
elsif trend.trend_type == "VersionRelease" && trend.trend.present?
json.partial! "version_releases/simple_version_release", locals: {version: trend.trend}
elsif trend.trend_type == "CommitLog"
commit_log = trend.trend

View File

@ -6,6 +6,7 @@ json.setting do
json.name default_setting.name
json.nav_logo_url default_setting.nav_logo_url&.[](1..-1)
json.login_logo_url default_setting.login_logo_url&.[](1..-1)
json.index_logo_url default_setting.index_logo_url&.[](1..-1)
json.tab_logo_url default_setting.tab_logo_url.present? ? default_setting.tab_logo_url&.[](1..-1) : "favicon.ico"
json.site_page_deploy_domain @deploy_domain

View File

@ -0,0 +1 @@
json.(topic, :id, :type, :title, :uuid, :url, :description, :identifier, :image, :location, :labels, :date)

View File

@ -34,7 +34,7 @@ json.topics do
when 'Topic::ServiceTerm'
json.partial! 'service_term', locals: {service_term: topic}
else
json.nil!
json.partial! 'all', locals: {topic: topic}
end
end
end
@ -72,7 +72,7 @@ json.topics do
when 'Topic::ServiceTerm'
json.partial! 'service_term', locals: {service_term: topic}
else
json.nil!
json.partial! 'all', locals: {topic: topic}
end
end
end

View File

@ -480,6 +480,7 @@ Rails.application.routes.draw do
get :recommend, on: :collection
post :auto_score, on: :collection
post :update_expert_audit, on: :collection
post :tzb_actived, on: :collection
member do
get :enroll_list
get :ranking_list
@ -867,6 +868,7 @@ Rails.application.routes.draw do
get '/', to: 'dashboards#index'
get '/baidu_tongji', to: 'dashboards#baidu_tongji'
get '/baidu_tongji_auth', to: 'dashboards#baidu_tongji_auth'
resources :topics
namespace :topic do
resources :service_terms
resources :technical_discussions

View File

@ -33,3 +33,8 @@ cache_async_reset:
queue: cache
args:
- "platform_statistic_service"
sync_competition_tzb_user:
cron: "*/5 * * * *"
class: "SyncCompetitionTzbUserJob"
queue: default

View File

@ -0,0 +1,21 @@
class CreateCompetitionTzbUsers < ActiveRecord::Migration[5.2]
def change
# data = '{"Code":"Ok","Message":"成功","Data":[{"corp_id":123456,"match_id":666,"user_uid":"uid_y0gqNR3EesqZVgA","project_pid":"pid_123001","activation_code":"V2nyoEYzl2zRaVySpldc","project_status":"not_finished","project_status_text":"未提交",
# "status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_JHnTBdt8GA3tziq","project_pid":"pid_123002","activation_code":"nde8u5HNQ7qqXjkBIQG0","project_status":"submit_to","project_status_text":"已提交","status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_2tCNcoKX8T8oHvk","project_pid":"pid_123003","activation_code":"iZQCh3mfuJ8ESrUPwGRo","project_status":"pass_by","project_status_text":"审核通过","status_level":"school","status_level_text":"校级","school_code":"10001","school_name":"北京大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_DziaXaNTkyS1M05","project_pid":"pid_123004","activation_code":"c42BKyehYWAxeAqjLdc8","project_status":"not_pass_by","project_status_text":"审核未通过","status_level":"province","status_level_text":"省级","school_code":"10001","school_name":"北京大学","province_name":"北京"}]}'
create_table :competition_tzb_users do |t|
t.string :user_uid
t.string :user_email
t.string :activation_code
t.text :info_json
t.integer :user_id
t.string :pwd
t.boolean :actived, default: false
t.timestamps
end
add_index :competition_tzb_users, :user_uid
add_index :competition_tzb_users, :activation_code
add_index :competition_tzb_users, :user_id
end
end