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

dev_new_shixunsrepository
杨树林 5 years ago
commit fee9b716f2

@ -106,3 +106,6 @@ gem 'omniauth-oauth2', '~> 1.6.0'
# global var # global var
gem 'request_store' gem 'request_store'
# 敏感词汇
gem 'harmonious_dictionary', '~> 0.0.1'

@ -53,13 +53,15 @@ module GitHelper
end end
# 添加目录 # 添加目录
def git_add_folder(folder_path, author_name, author_email, message) def git_add_folder(repo_path, folder_path, author_name, author_email, message)
GitService.add_tree(file_path: folder_path, message: message, author_name: author_name, author_email: author_email) GitService.add_tree(repo_path: repo_path, file_path: folder_path, message: message, author_name: author_name,
author_email: author_email)
end end
# 删除文件 # 删除文件
def git_delete_file(file_path, author_name, author_email, message) def git_delete_file(repo_path, file_path, author_name, author_email, message)
GitService.delete_file(file_path: file_path, message: message, author_name: author_name, author_email: author_email) GitService.delete_file(repo_path, repo_path, file_path: file_path, message: message, author_name: author_name,
author_email: author_email)
end end
# 版本库Fork功能 # 版本库Fork功能

@ -85,7 +85,7 @@ class DiscussesController < ApplicationController
:hidden => !current_user.admin?) # 管理员回复的能够显示 :hidden => !current_user.admin?) # 管理员回复的能够显示
rescue Exception => e rescue Exception => e
uid_logger_error("create discuss failed : #{e.message}") uid_logger_error("create discuss failed : #{e.message}")
raise Educoder::TipException.new("评论异常") raise Educoder::TipException.new("评论异常,原因:#{e.message}")
end end
end end
@ -97,7 +97,7 @@ class DiscussesController < ApplicationController
:dis_type => @discuss.dis_type, :position => @discuss.position) :dis_type => @discuss.dis_type, :position => @discuss.position)
rescue Exception => e rescue Exception => e
uid_logger_error("reply discuss failed : #{e.message}") uid_logger_error("reply discuss failed : #{e.message}")
raise Educoder::TipException.new("回复评论异常") raise Educoder::TipException.new("回复评论异常,原因: #{e.message}")
end end
end end

@ -16,7 +16,7 @@ class ShixunsController < ApplicationController
:propaedeutics, :departments, :apply_shixun_mirror, :jupyter_exec, :propaedeutics, :departments, :apply_shixun_mirror, :jupyter_exec,
:get_mirror_script, :download_file, :shixun_list, :batch_send_to_course] :get_mirror_script, :download_file, :shixun_list, :batch_send_to_course]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy,
:add_file, :jupyter_exec] :add_file, :jupyter_exec, :upload_git_file, :delete_git_file, :upload_git_folder]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public, :upload_git_folder, before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public, :upload_git_folder,
:shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file, :shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file,
@ -905,7 +905,7 @@ class ShixunsController < ApplicationController
author_name = current_user.real_name author_name = current_user.real_name
author_email = current_user.git_mail author_email = current_user.git_mail
message = params[:message] || "upload folder by browser" message = params[:message] || "upload folder by browser"
git_add_folder(@path, author_name, author_email, message) git_add_folder(@repo_path, @path, author_name, author_email, message)
render_ok render_ok
end end
@ -913,7 +913,7 @@ class ShixunsController < ApplicationController
author_name = current_user.real_name author_name = current_user.real_name
author_email = current_user.git_mail author_email = current_user.git_mail
message = params[:message] || "delete file by browser" message = params[:message] || "delete file by browser"
git_delete_file(@path, author_name, author_email, message) git_delete_file(@repo_path, @path, author_name, author_email, message)
render_ok render_ok
end end
@ -1095,9 +1095,8 @@ private
@repo_path = if params[:secret_repository] @repo_path = if params[:secret_repository]
@shixun.shixun_secret_repository&.repo_path @shixun.shixun_secret_repository&.repo_path
else else
@shixun.try(:repo_path) @shixun.repo_path
end end
logger.info("######{@repo_path}")
@path = params[:path] @path = params[:path]
end end

@ -81,6 +81,8 @@ class Course < ApplicationRecord
# 老版的members弃用 现用course_members # 老版的members弃用 现用course_members
has_many :members has_many :members
validate :validate_sensitive_string
scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) } scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) }
scope :ended, ->(is_end = true) { where(is_end: is_end) } scope :ended, ->(is_end = true) { where(is_end: is_end) }
scope :processing, -> { where(is_end: false) } scope :processing, -> { where(is_end: false) }
@ -435,4 +437,8 @@ class Course < ApplicationRecord
self.laboratory = Laboratory.current if laboratory_id.blank? self.laboratory = Laboratory.current if laboratory_id.blank?
end end
def validate_sensitive_string
raise("课堂名称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(name)
end
end end

@ -6,4 +6,10 @@ class CourseList < ApplicationRecord
has_many :gtask_banks has_many :gtask_banks
has_many :gtopic_banks has_many :gtopic_banks
belongs_to :user belongs_to :user
validate :validate_sensitive_string
def validate_sensitive_string
raise("课程名称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(name)
end
end end

@ -11,6 +11,8 @@ class Discuss < ApplicationRecord
belongs_to :dis, polymorphic: true belongs_to :dis, polymorphic: true
belongs_to :challenge, optional: true belongs_to :challenge, optional: true
validate :validate_sensitive_string
after_create :send_tiding after_create :send_tiding
scope :children, -> (discuss_id){ where(parent_id: discuss_id).includes(:user).reorder(created_at: :asc) } scope :children, -> (discuss_id){ where(parent_id: discuss_id).includes(:user).reorder(created_at: :asc) }
@ -69,4 +71,8 @@ class Discuss < ApplicationRecord
} }
tidings.create!(base_attrs.merge(user_id: send_user_id)) tidings.create!(base_attrs.merge(user_id: send_user_id))
end end
def validate_sensitive_string
raise("内容包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(content)
end
end end

@ -16,6 +16,7 @@ class Memo < ApplicationRecord
has_many :children, foreign_key: :parent_id, class_name: 'Memo' has_many :children, foreign_key: :parent_id, class_name: 'Memo'
has_many :attachments, as: :container, dependent: :destroy has_many :attachments, as: :container, dependent: :destroy
has_many :tidings, as: :container, dependent: :destroy has_many :tidings, as: :container, dependent: :destroy
validate :validate_sensitive_string
scope :field_for_list, lambda{ scope :field_for_list, lambda{
select([:id, :subject, :author_id, :sticky, :updated_at, :language, :reward, :all_replies_count, :viewed_count, :forum_id]) select([:id, :subject, :author_id, :sticky, :updated_at, :language, :reward, :all_replies_count, :viewed_count, :forum_id])
@ -54,4 +55,9 @@ class Memo < ApplicationRecord
self.tidings << Tiding.new(tiding_attr) self.tidings << Tiding.new(tiding_attr)
end end
def validate_sensitive_string
raise("标题包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(subject)
raise("内容包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(content)
end
end end

@ -178,13 +178,8 @@ class User < ApplicationRecord
validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, case_sensitive: false validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, case_sensitive: false
validates_length_of :login, maximum: LOGIN_LENGTH_LIMIT validates_length_of :login, maximum: LOGIN_LENGTH_LIMIT
validates_length_of :mail, maximum: MAIL_LENGTH_LMIT validates_length_of :mail, maximum: MAIL_LENGTH_LMIT
# validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true validate :validate_sensitive_string
# validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true
validate :validate_password_length validate :validate_password_length
#validate :validate_ID_number
#validates_format_of :ID_number, with: VALID_NUMBER_REGEX, multiline: true, message: "身份证号格式不对"
# validates :nickname, presence: true, length: { maximum: 10 }
# validates :lastname, presence: true
# 删除自动登录的token一旦退出下次会提示需要登录 # 删除自动登录的token一旦退出下次会提示需要登录
def delete_autologin_token(value) def delete_autologin_token(value)
@ -727,6 +722,11 @@ class User < ApplicationRecord
end end
end end
def validate_sensitive_string
raise("真实姓名包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(lastname)
raise("昵称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(nickname)
end
def set_laboratory def set_laboratory
return unless new_record? return unless new_record?

File diff suppressed because it is too large Load Diff

@ -0,0 +1,66 @@
6-4tianwang
89-64cdjp
ADMIN
Administrator
asshole
BLOWJOB
chinaliberal
chinamz
chinesenewsnet
Clockgemstone
creaders
Crestbone
dajiyuan
dfdz
DICK
falun
falundafa
Feelmistone
freechina
freenet
fuck
gcd
Gruepin
Guichuideng
HACKING
hongzhi
hrichina
HUANET
hypermart.net
incest
jiangdongriji
jiaochuang
jiaochun
KEFU
KISSMYASS
lihongzhi
minghui
minghuinews
nacb
Neckromancer
NMIS
PAPER64
penis
qiangjian
renminbao
renmingbao
SHIT
SUCKPENIS
taip
tibetalk
triangle
triangleboy
Tringel
UltraSurf
ustibet
voachinese
wangce
WEBZEN
wstaiji
xinsheng
YUMING
zangdu
ZHENGJIAN
ZHENGJIANWANG
ZHENSHANREN
zhuanfalun

@ -0,0 +1,67 @@
---
- 6-4tianwang
- 89-64cdjp
- ADMIN
- Administrator
- asshole
- BLOWJOB
- chinaliberal
- chinamz
- chinesenewsnet
- Clockgemstone
- creaders
- Crestbone
- dajiyuan
- dfdz
- DICK
- falun
- falundafa
- Feelmistone
- freechina
- freenet
- fuck
- gcd
- Gruepin
- Guichuideng
- HACKING
- hongzhi
- hrichina
- HUANET
- hypermart.net
- incest
- jiangdongriji
- jiaochuang
- jiaochun
- KEFU
- KISSMYASS
- lihongzhi
- minghui
- minghuinews
- nacb
- Neckromancer
- NMIS
- PAPER64
- penis
- qiangjian
- renminbao
- renmingbao
- SHIT
- SUCKPENIS
- taip
- tibetalk
- triangle
- triangleboy
- Tringel
- UltraSurf
- ustibet
- voachinese
- wangce
- WEBZEN
- wstaiji
- xinsheng
- YUMING
- zangdu
- ZHENGJIAN
- ZHENGJIANWANG
- ZHENSHANREN
-

@ -56,12 +56,17 @@
.ysltitbt{ .ysltitbt{
float: left; float: left;
padding-top: 31px; padding-top: 28px;
padding-left: 25px; padding-left: 25px;
font-size: 21px; font-size: 21px;
color: #05101A; color: #05101a;
text-align: left; text-align: left;
font-weight:bold; font-weight: bold;
max-width: 805px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block;
} }
.markdownysltext{ .markdownysltext{
font-size: 14px; font-size: 14px;

@ -1039,17 +1039,17 @@ submittojoinclass=(value)=>{
` `
} }
</style> </style>
{/*<li className={`pr `}>*/} <li className={`pr `}>
{/* <Popover placement="bottom" content={contents} trigger="click" >*/} <Popover placement="bottom" content={contents} trigger="click" >
{/* <div className=" sortinxdirection mr10">*/} <div className=" sortinxdirection mr10">
{/* <div style={{*/} <div style={{
{/* color:"#fff"*/} color:"#fff"
{/* }}>*/} }}>
{/* 题库*/} 题库
{/* </div>*/} </div>
{/* </div>*/} </div>
{/* </Popover>*/} </Popover>
{/*</li>*/} </li>
<li <li
style={{display: this.props.Headertop === undefined ? 'none' : this.props.Headertop.auth === null ? 'none' : 'block'}} style={{display: this.props.Headertop === undefined ? 'none' : this.props.Headertop.auth === null ? 'none' : 'block'}}

@ -80,7 +80,7 @@ class TPMRepositoryComponent extends Component {
let url = `/shixuns/${id}/file_content.json`; let url = `/shixuns/${id}/file_content.json`;
axios.post(url, { axios.post(url, {
path: path, path: path,
secret_repository: this.props.secret_repository_tab secret_repository: this.props.secret_repository_tab===false?undefined:this.props.secret_repository_tab
}).then((response) => { }).then((response) => {
trace_collapse('repository res: ', response) trace_collapse('repository res: ', response)

@ -72,7 +72,7 @@ class TPMRepositoryComponentdetails extends Component {
let url = `/shixuns/${id}/file_content.json`; let url = `/shixuns/${id}/file_content.json`;
axios.post(url, { axios.post(url, {
path: path, path: path,
secret_repository: this.props.secret_repository_tab secret_repository: this.props.secret_repository_tab===false?undefined:this.props.secret_repository_tab
}).then((response) => { }).then((response) => {
trace_collapse('repository res: ', response) trace_collapse('repository res: ', response)

@ -118,7 +118,7 @@ class RepositoryAddFile extends Component {
path:values.path, path:values.path,
message:values.message, message:values.message,
content:this.extend_editor.getValue(), content:this.extend_editor.getValue(),
secret_repository:Repositoryflag secret_repository:Repositoryflag===false?undefined:Repositoryflag
}).then((result)=>{ }).then((result)=>{
if(result){ if(result){
this.props.history.push(Repositoryflag===true?`/shixuns/${shixunId}/secret_repository`:`/shixuns/${shixunId}/repository`) this.props.history.push(Repositoryflag===true?`/shixuns/${shixunId}/secret_repository`:`/shixuns/${shixunId}/repository`)

@ -66,10 +66,10 @@ class RepositoryAddFileupload_files extends Component {
let matchpath =this.props.match.path; let matchpath =this.props.match.path;
let Repositoryflag =false; let Repositoryflag =undefined;
if( matchpath.indexOf("repository")>-1){ if( matchpath.indexOf("repository")>-1){
Repositoryflag =false; Repositoryflag =undefined;
} }
if(matchpath.indexOf("secret_repository")>-1){ if(matchpath.indexOf("secret_repository")>-1){
Repositoryflag =true; Repositoryflag =true;
@ -135,25 +135,30 @@ class RepositoryAddFileupload_files extends Component {
// }; // };
let matchpath =this.props.match.path; let matchpath =this.props.match.path;
let Repositoryflagtype =false;
let Repositoryflag =""; let Repositoryflag ="";
let newdata;
if( matchpath.indexOf("repository")>-1){ if( matchpath.indexOf("repository")>-1){
Repositoryflag ="repository"; Repositoryflag ="repository";
Repositoryflagtype =false; newdata={
path:this.state.filspath,
message:this.state.message,
}
} }
if(matchpath.indexOf("secret_repository")>-1){ if(matchpath.indexOf("secret_repository")>-1){
Repositoryflag ="secret_repository"; Repositoryflag ="secret_repository";
Repositoryflagtype =true; newdata={
path:this.state.filspath,
message:this.state.message,
secret_repository:true
} }
}
const props = { const props = {
height:300, height:300,
multiple: true, multiple: true,
data:{ data:newdata,
path:this.state.filspath,
message:this.state.message,
secret_repository:Repositoryflagtype
},
fileList:this.state.fileList, fileList:this.state.fileList,
// showUploadList:false, // showUploadList:false,
action: `${getupload_git_file(shixunId)}`, action: `${getupload_git_file(shixunId)}`,

@ -122,7 +122,7 @@ class RepositoryCodeEditor extends Component {
const path = pathArray.join('/') const path = pathArray.join('/')
this.setState({ codeSaving: true }) this.setState({ codeSaving: true })
axios.post(url, { axios.post(url, {
secret_repository: this.props.secret_repository_tab, secret_repository: this.props.secret_repository_tab===false?undefined:this.props.secret_repository_tab,
content: this.extend_editor.getValue(), content: this.extend_editor.getValue(),
// type: forTest === true ? 1 : 0, // type: forTest === true ? 1 : 0,
path: path, path: path,

@ -120,16 +120,16 @@ class Repositoryfile extends Component{
handleSubmit = (e) => { handleSubmit = (e) => {
let {path}=this.state; let {path}=this.state;
let matchpath =this.props.match.path; let matchpath =this.props.match.path;
let flag =false; let flag =undefined;
if( matchpath.indexOf("repository")>-1){ if( matchpath.indexOf("repository")>-1){
flag =false; flag =undefined;
} }
if(matchpath.indexOf("secret_repository")>-1){ if(matchpath.indexOf("secret_repository")>-1){
flag =true; flag =true;
} }
if(this.props.selectupfils===true){ if(this.props.selectupfils===true){
console.log(path)
this.props.selectupfilspath(path); this.props.selectupfilspath(path);
this.props.showNotification("选择文件目录成功") this.props.showNotification("选择文件目录成功")
this.props.hideNewFolder(); this.props.hideNewFolder();
@ -141,7 +141,7 @@ class Repositoryfile extends Component{
let paths=path+values.name; let paths=path+values.name;
axios.post(url,{ axios.post(url,{
path: paths, path: paths,
secret_repository:flag, secret_repository:flag===false?undefined:flag,
}).then((result)=>{ }).then((result)=>{
if(result){ if(result){
if(result.data.status===0){ if(result.data.status===0){

@ -35,7 +35,7 @@ class TPMRepositoryCommits extends Component {
let collaborators=`/shixuns/`+id+`/commits.json`; let collaborators=`/shixuns/`+id+`/commits.json`;
axios.post(collaborators, { axios.post(collaborators, {
secret_repository: this.props.secret_repository_tab secret_repository: this.props.secret_repository_tab===false?undefined:this.props.secret_repository_tab
}).then((response)=> { }).then((response)=> {
if(response.status===200){ if(response.status===200){

@ -138,15 +138,26 @@
} }
.shixunstartbutton33BD8C{ .shixunstartbutton33BD8C{
background: #33BD8C !important; /* border: #33BD8C !important; */
border: #33BD8C !important;
cursor: inherit !important; cursor: inherit !important;
border: 1px solid #33BD8C !important;
background: transparent !important;
color: #33BD8C !important;
box-shadow: none;
text-shadow: none;
} }
.shixunstartbuttonFF6601{ .shixunstartbuttonFF6601{
background: #FF6601 !important; /*background: #FF6601 !important;*/
border: #FF6601 !important; /*border: #FF6601 !important;*/
/*cursor: inherit !important;*/
/* border: #33BD8C !important; */
cursor: inherit !important; cursor: inherit !important;
border: 1px solid #FF6601 !important;
background: transparent !important;
color: #FF6601 !important;
box-shadow: none;
text-shadow: none;
} }
.shixunstartbutton666666{ .shixunstartbutton666666{

@ -107,7 +107,10 @@ class ShixunsIndex extends Component {
this.setState({ this.setState({
parsedid:parsed.id, parsedid:parsed.id,
newtag_level:nawparsed, newtag_level:nawparsed,
newpalce:newpalce tag_level:nawparsed,
newpalce:newpalce,
tag_id:parsed.id,
keyword: _keyword || keyword,
}) })
this.shixunresultend(params); this.shixunresultend(params);
} }

Loading…
Cancel
Save