|
|
@ -179,6 +179,16 @@ class ShixunsController < ApplicationController
|
|
|
|
ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => @new_shixun.id)
|
|
|
|
ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => @new_shixun.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 同步配置
|
|
|
|
|
|
|
|
@shixun.shixun_service_configs.each do |config|
|
|
|
|
|
|
|
|
ShixunServiceConfig.create!(:shixun_id => @new_shixun.id,
|
|
|
|
|
|
|
|
:cpu_limit => config.cpu_limit,
|
|
|
|
|
|
|
|
:lower_cpu_limit => config.lower_cpu_limit,
|
|
|
|
|
|
|
|
:memory_limit => config.memory_limit,
|
|
|
|
|
|
|
|
:request_limit => config.request_limit,
|
|
|
|
|
|
|
|
:mirror_repository_id => config.mirror_repository_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# fork版本库
|
|
|
|
# fork版本库
|
|
|
|
logger.info("###########fork_repo_path: ######{@repo_path}")
|
|
|
|
logger.info("###########fork_repo_path: ######{@repo_path}")
|
|
|
|
project_fork(@new_shixun, @repo_path, current_user.login)
|
|
|
|
project_fork(@new_shixun, @repo_path, current_user.login)
|
|
|
@ -367,11 +377,6 @@ class ShixunsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
def update
|
|
|
|
h = {test_set_permission: params[:test_set_permission], code_hidden: params[:code_hidden],
|
|
|
|
|
|
|
|
task_pass: params[:task_pass], hide_code: params[:hide_code], forbid_copy: params[:forbid_copy]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s_params = shixun_params.merge(h)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
@shixun.shixun_mirror_repositories.destroy_all
|
|
|
|
@shixun.shixun_mirror_repositories.destroy_all
|
|
|
@ -384,8 +389,8 @@ class ShixunsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@shixun.update_attributes(s_params)
|
|
|
|
@shixun.update_attributes(shixun_params)
|
|
|
|
@shixun.shixun_info.update_attributes(description: params[:description], evaluate_script: params[:evaluate_script])
|
|
|
|
@shixun.shixun_info.update_attributes(shixun_info_params)
|
|
|
|
@shixun.shixun_schools.delete_all
|
|
|
|
@shixun.shixun_schools.delete_all
|
|
|
|
if params[:scope_partment].present? && params[:user_scope].to_i == 1
|
|
|
|
if params[:scope_partment].present? && params[:user_scope].to_i == 1
|
|
|
|
arr = []
|
|
|
|
arr = []
|
|
|
@ -402,13 +407,8 @@ class ShixunsController < ApplicationController
|
|
|
|
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
|
|
|
|
# 超级管理员和运营人员才能保存 中间层服务器pod信息的配置
|
|
|
|
if current_user.admin? || current_user.business?
|
|
|
|
if current_user.admin? || current_user.business?
|
|
|
|
@shixun.shixun_service_configs.destroy_all
|
|
|
|
@shixun.shixun_service_configs.destroy_all
|
|
|
|
params[:mirror_id].each_with_index do |mirror_id, index|
|
|
|
|
params[:shixun_service_configs].each do |config|
|
|
|
|
ShixunServiceConfig.create!(:shixun_id => @shixun.id,
|
|
|
|
@shixun.shixun_service_configs.create!(config)
|
|
|
|
:cpu_limit => params[:cpu_limit][index],
|
|
|
|
|
|
|
|
:lower_cpu_limit => params[:lower_cpu_limit][index],
|
|
|
|
|
|
|
|
:memory_limit => params[:memory_limit][index],
|
|
|
|
|
|
|
|
:request_limit => params[:request_limit][index],
|
|
|
|
|
|
|
|
:mirror_repository_id => mirror_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
@ -446,6 +446,7 @@ class ShixunsController < ApplicationController
|
|
|
|
@choice_small_type = @shixun.small_mirror_id
|
|
|
|
@choice_small_type = @shixun.small_mirror_id
|
|
|
|
@main_type = shixun_main_type
|
|
|
|
@main_type = shixun_main_type
|
|
|
|
@small_type = shixun_small_type
|
|
|
|
@small_type = shixun_small_type
|
|
|
|
|
|
|
|
@configs = @shixun.shixun_service_configs
|
|
|
|
#@mirror_script = MirrorScript.select([:id, :script_type]).find(@shixun.mirror_script_id).attributes if @shixun.mirror_script_id && @shixun.mirror_script_id != 0
|
|
|
|
#@mirror_script = MirrorScript.select([:id, :script_type]).find(@shixun.mirror_script_id).attributes if @shixun.mirror_script_id && @shixun.mirror_script_id != 0
|
|
|
|
# @shixun_main_mirror = @shixun.show_shixun_mirror
|
|
|
|
# @shixun_main_mirror = @shixun.show_shixun_mirror
|
|
|
|
# @script_type = @shixun.script_tag.try(:script_type) || "无"
|
|
|
|
# @script_type = @shixun.script_tag.try(:script_type) || "无"
|
|
|
@ -734,7 +735,13 @@ private
|
|
|
|
def shixun_params
|
|
|
|
def shixun_params
|
|
|
|
raise("实训名称不能为空") if params[:name].blank?
|
|
|
|
raise("实训名称不能为空") if params[:name].blank?
|
|
|
|
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
|
|
|
|
params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission,
|
|
|
|
:task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id)
|
|
|
|
:task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden,
|
|
|
|
|
|
|
|
:hide_code, :forbid_copy)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def shixun_info_params
|
|
|
|
|
|
|
|
raise("实训描述不能为空") if params[:description].blank?
|
|
|
|
|
|
|
|
raise("评测脚本不能为空") if params[:evaluate_script].blank?
|
|
|
|
|
|
|
|
params.require(:shixun_info).permit(:description, :evaluate_script)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def find_shixun
|
|
|
|
def find_shixun
|
|
|
|