Merge branch 'dev_jupyter' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_jupyter

chromesetting
杨树林 5 years ago
commit 2c982d55f1

@ -28,6 +28,7 @@ class AttachmentsController < ApplicationController
def create def create
# 1. 本地存储 # 1. 本地存储
# 2. 上传到云 # 2. 上传到云
begin
upload_file = params["file"] || params["#{params[:file_param_name]}"] # 这里的file_param_name是为了方便其他插件名称 upload_file = params["file"] || params["#{params[:file_param_name]}"] # 这里的file_param_name是为了方便其他插件名称
uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}") uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}")
raise "未上传文件" unless upload_file raise "未上传文件" unless upload_file
@ -74,6 +75,10 @@ class AttachmentsController < ApplicationController
end end
render_json render_json
rescue => e
uid_logger_error(e.message)
tip_exception(e.message)
end
end end
def destroy def destroy

@ -469,6 +469,8 @@ class ShixunsController < ApplicationController
# 实训测试集附件 # 实训测试集附件
def upload_data_sets def upload_data_sets
begin
upload_file = params["file"] upload_file = params["file"]
raise "未上传文件" unless upload_file raise "未上传文件" unless upload_file
folder = edu_setting('shixun_folder') folder = edu_setting('shixun_folder')
@ -492,7 +494,6 @@ class ShixunsController < ApplicationController
@attachment.digest = digest @attachment.digest = digest
@attachment.author_id = current_user.id @attachment.author_id = current_user.id
@attachment.disk_directory = tpm_folder @attachment.disk_directory = tpm_folder
@attachment.cloud_url = remote_path
@attachment.container_id = @shixun.id @attachment.container_id = @shixun.id
@attachment.container_type = @shixun.class.name @attachment.container_type = @shixun.class.name
@attachment.attachtype = 2 @attachment.attachtype = 2
@ -501,6 +502,10 @@ class ShixunsController < ApplicationController
logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}" logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}"
end end
render_ok render_ok
rescue => e
uid_logger_error(e.message)
tip_exception(e.message)
end
end end
# 多文件删除 # 多文件删除
@ -1105,4 +1110,16 @@ private
ext ext
end end
def delete_file(file_path)
File.delete(file_path) if File.exist?(file_path)
end
def md5_file(temp_file)
md5 = Digest::MD5.new
temp_file.rewind
while (buffer = temp_file.read(8192))
md5.update(buffer)
end
md5.hexdigest
end
end end

@ -118,7 +118,7 @@ class TPMBanner extends Component {
if (prevProps != this.props) { if (prevProps != this.props) {
let shixunopenprocess=window.localStorage.shixunopenprocess; let shixunopenprocess=window.localStorage.shixunopenprocess;
let openopenpublictype=window.localStorage.openopenpublictype; let openopenpublictype=window.localStorage.openopenpublictype;
if(this.props.shixunsDetails.shixun_status === 0 && this.props.identity < 5){ if(this.props.shixunsDetails&&this.props.shixunsDetails.shixun_status === 0 && this.props.identity < 5){
if(shixunopenprocess===undefined||shixunopenprocess===false){ if(shixunopenprocess===undefined||shixunopenprocess===false){
this.setState({ this.setState({
openknow:true openknow:true
@ -130,7 +130,7 @@ class TPMBanner extends Component {
} }
} }
if(this.props.shixunsDetails.shixun_status === 2 && this.props.shixunsDetails.public===0 && this.props.identity < 5){ if(this.props.shixunsDetails&&this.props.shixunsDetails.shixun_status === 2 && this.props.shixunsDetails&&this.props.shixunsDetails.public===0 && this.props.identity < 5){
if(openopenpublictype===undefined||openopenpublictype===false){ if(openopenpublictype===undefined||openopenpublictype===false){
this.setState({ this.setState({
openshowpublictype:true openshowpublictype:true

Loading…
Cancel
Save