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

dev_daiao
daiao 5 years ago
commit 75f76e1400

@ -18,9 +18,9 @@ class AttachmentsController < ApplicationController
pdf_attachment = params[:disposition] || "attachment" pdf_attachment = params[:disposition] || "attachment"
if pdf_attachment == "inline" if pdf_attachment == "inline"
send_file absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: 'application/pdf'
else else
send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream')
end end
update_downloads(@file) update_downloads(@file)
end end

@ -27,12 +27,21 @@ class Attachment < ApplicationRecord
validates_length_of :description, maximum: 100 validates_length_of :description, maximum: 100
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def diskfile def diskfile
File.join(File.join(Rails.root, "files"), disk_directory.to_s, disk_filename.to_s) File.join(File.join(Rails.root, "files"), disk_directory.to_s, disk_filename.to_s)
end end
def title def title
filename title = filename
if container.is_a?(StudentWork) && author_id != User.current.id
course = container&.homework_common&.course
unless User.current.teacher_of_course?(course)
title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename)
end
end
title
end end
def downloads_count def downloads_count

@ -165,7 +165,7 @@ class Competition < ApplicationRecord
def get_module_name type def get_module_name type
case type case type
when 'home' then '首页' when 'home' then '赛制介绍'
when 'enroll' then '报名' when 'enroll' then '报名'
when 'inform' then '通知公告' when 'inform' then '通知公告'
when 'chart' then '排行榜' when 'chart' then '排行榜'

@ -25,23 +25,23 @@ class CreateDiffRecordService < ApplicationService
index = 0 index = 0
fragment_size = 1 fragment_size = 1
Diffy::Diff.new(before, after).each do |line| Diffy::Diff.new(before, after).each do |line|
unless line =~ /^[\+-]/ unless line.include?("\\ 文件尾没有 newline 字符")
if arr.empty? && index < fragment_size unless line =~ /^[\+-]/
content += line if arr.empty? && index < fragment_size
index += 1 content += line
else index += 1
index = 0 else
arr << line index = 0
arr.shift if arr.size > fragment_size arr << line
arr.shift if arr.size > fragment_size
end
next
end end
next
end
content += arr.join('') if arr.present? content += arr.join('') if arr.present?
Rails.logger.info("diff_line_arr:#{arr.join('')}") content += line
content += line arr.clear
arr.clear end
Rails.logger.info("diff_line:#{line}")
end end
content content
end end

@ -11,7 +11,7 @@ json.update_user_name @is_evaluation ? "匿名" : @work.update_user.try(:real_na
json.update_atta @homework.late_duration && @is_author json.update_atta @homework.late_duration && @is_author
json.attachments @attachments do |atta| json.attachments @attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false} json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false, }
end end
unless @is_evaluation unless @is_evaluation

@ -413,7 +413,7 @@ class AccountBasic extends Component {
//昵称 //昵称
handleSubmitName(rule, value, callback){ handleSubmitName(rule, value, callback){
if (value) { if (value) {
let iconRule1 = /[`~!@#$%^&()\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im; let iconRule1 = /[`~!@#$%^&*()\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im;
// 判断是否含有emoji表情 // 判断是否含有emoji表情
let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
// 如果为true字符串含有emoji表情 false不含 // 如果为true字符串含有emoji表情 false不含
@ -436,22 +436,22 @@ class AccountBasic extends Component {
// 姓名 // 姓名
handleSubmitNames(rule, value, callback){ handleSubmitNames(rule, value, callback){
if (value) { if (value) {
let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im; let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&()——\-+={}|《》?:“”【】、;‘’,。、]/im;
// 判断是否含有emoji表情 // 判断是否含有emoji表情
let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
// 如果为true字符串含有emoji表情 false不含 // 如果为true字符串含有emoji表情 false不含
const iconRule2s =iconRule2.test(value); const iconRule2s =iconRule2.test(value);
// 如果为true字符串含有特殊符号 false不 // 如果为true字符串含有特殊符号 false不
const iconRule1s =iconRule1.test(value); const iconRule1s =iconRule1.test(value);
if (iconRule2s===true|| iconRule1s===true) { if (iconRule2s===true|| iconRule1s===true) {
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
else if(value.length<2){ else if(value.length<2){
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
}else if(value.length>=11){ }else if(value.length>=11){
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
} }
callback(); callback();
} }
@ -606,7 +606,7 @@ class AccountBasic extends Component {
], ],
validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit validateTrigger: 'onSubmit', // 设置进行表单验证的时机为onSubmit
})( })(
<Input placeholder={`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`} className="yslgraduainputedit" disabled={!showRealName && this.state.forDisable == true } addonAfter={ <Input placeholder={`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`} className="yslgraduainputedit" disabled={!showRealName && this.state.forDisable == true } addonAfter={
<i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"} <i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"}
onClick={()=>this.showOrHide(showRealName)}></i> onClick={()=>this.showOrHide(showRealName)}></i>

@ -453,22 +453,22 @@ class RealNameCertificationModal extends Component{
// 姓名 // 姓名
handleSubmitNames(rule, value, callback){ handleSubmitNames(rule, value, callback){
if (value) { if (value) {
let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im; let iconRule1 = /[`~!@#$%^&()_\-+=<>?:"{}|,.\/;'\\[\]·~@#¥%……&()——\-+={}|《》?:“”【】、;‘’,。、]/im;
// 判断是否含有emoji表情 // 判断是否含有emoji表情
let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig; let iconRule2 = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
// 如果为true字符串含有emoji表情 false不含 // 如果为true字符串含有emoji表情 false不含
const iconRule2s =iconRule2.test(value); const iconRule2s =iconRule2.test(value);
// 如果为true字符串含有特殊符号 false不 // 如果为true字符串含有特殊符号 false不
const iconRule1s =iconRule1.test(value); const iconRule1s =iconRule1.test(value);
if (iconRule2s===true|| iconRule1s===true) { if (iconRule2s===true|| iconRule1s===true) {
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
else if(value.length<2){ else if(value.length<2){
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
}else if(value.length>=11){ }else if(value.length>=11){
callback('2-10位中英文、数字'); callback('2-10位中英文、数字');
} }
} }
callback(); callback();
} }

Loading…
Cancel
Save