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

dev_unstable
hjm 6 years ago
commit 9365c038f2

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

@ -1,5 +1,5 @@
class Users::VideoAuthsController < Users::BaseController class Users::VideoAuthsController < Users::BaseController
before_action :private_user_resources!, :require_auth_teacher! before_action :private_user_resources!, :check_account, :require_auth_teacher!
def create def create
result = Videos::CreateAuthService.call(observed_user, create_params) result = Videos::CreateAuthService.call(observed_user, create_params)

@ -1,5 +1,5 @@
class Users::VideosController < Users::BaseController class Users::VideosController < Users::BaseController
before_action :private_user_resources!, :require_auth_teacher! before_action :private_user_resources!, :check_account, :require_auth_teacher!
helper_method :current_video helper_method :current_video

@ -52,7 +52,8 @@ module ApplicationHelper
shixun_id = shixun_id.blank? ? -1 : shixun_id.join(",") shixun_id = shixun_id.blank? ? -1 : shixun_id.join(",")
Shixun.select([:id, :name, :user_id, :challenges_count, :myshixuns_count, :trainee, :identifier]).where("id Shixun.select([:id, :name, :user_id, :challenges_count, :myshixuns_count, :trainee, :identifier]).where("id
in(#{shixun_id}) or homepage_show =1").unhidden.order("myshixuns_count desc, homepage_show asc").limit(3) in(#{shixun_id})").unhidden.order("homepage_show asc, myshixuns_count desc").limit(3)
end end
# 相关推荐 # 相关推荐

@ -268,7 +268,7 @@ class User < ApplicationRecord
# 实训路径管理员 # 实训路径管理员
def creator_of_subject?(subject) def creator_of_subject?(subject)
subject.user_id == id subject.user_id == id || admin?
end end
# 实训路径合作者、admin # 实训路径合作者、admin

@ -13,5 +13,3 @@ json.downloads_count attachment.downloads_count
json.created_on attachment.created_on json.created_on attachment.created_on
json.is_pdf attachment.is_pdf? json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)
# json.url download_url(attachment) unless attachment.locked?(@is_member)

@ -11,6 +11,7 @@ json.allow_statistics @is_manager
json.allow_send @user.logged? json.allow_send @user.logged?
json.allow_visit @subject.status > 1 || @is_manager json.allow_visit @subject.status > 1 || @is_manager
json.allow_add_member @is_manager json.allow_add_member @is_manager
json.is_creator @is_creator
if @subject.excellent if @subject.excellent
json.courses @courses do |course| json.courses @courses do |course|

@ -70,4 +70,9 @@ export function appendFileSizeToUploadFileAll(fileList) {
return item return item
}) })
} }
export const uploadNameSizeSeperator = '  ' export const uploadNameSizeSeperator = '  '
export const sortDirections = ["ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", ]

@ -17,7 +17,7 @@ export { updatePageParams as updatePageParams } from './RouterUti
export { bytesToSize as bytesToSize } from './UnitUtil'; export { bytesToSize as bytesToSize } from './UnitUtil';
export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll, isImageExtension, export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll, isImageExtension,
downloadFile } from './TextUtil' downloadFile, sortDirections } from './TextUtil'
export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil' export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil'

@ -27,35 +27,42 @@ class Fileslistitem extends Component{
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
showfiles=(value)=>{ showfiles=(list)=>{
let {discussMessage,coursesId}=this.props if(list.is_history_file===false){
let file_id=discussMessage.id // this.props.DownloadFileA(list.title,list.url)
let url="/files/"+file_id+"/histories.json" window.location.href=list.url;
axios.get(url,{ }else{
params:{ let {discussMessage,coursesId}=this.props
course_id:coursesId let file_id=discussMessage.id
}, let url="/files/"+file_id+"/histories.json"
}).then((result)=>{ axios.get(url,{
params:{
if(result.data.attachment_histories.length===0){ course_id:coursesId
// if(result.data.is_pdf===true){ },
// this.props.ShowOnlinePdf(result.data.url) }).then((result)=>{
// //预览pdf
// }else{ if(result.data.attachment_histories.length===0){
// // if(result.data.is_pdf===true){
// } // this.props.ShowOnlinePdf(result.data.url)
this.props.DownloadFileA(result.data.title,result.data.url) // //预览pdf
}else{ // }else{
this.setState({ //
Showoldfiles:true, // }
allfiles:result.data // this.props.DownloadFileA(result.data.title,result.data.url)
}) window.location.href=list.url;
} }else{
this.setState({
Showoldfiles:true,
}).catch((error)=>{ allfiles:result.data
console.log(error) })
}) }
}).catch((error)=>{
console.log(error)
})
}
} }
closaoldfilesprops=()=>{ closaoldfilesprops=()=>{
@ -191,13 +198,13 @@ class Fileslistitem extends Component{
{ {
this.props.isAdmin ? <a this.props.isAdmin ? <a
// href={"/courses/" + coursesId + "/graduation/graduation_tasks/" + categoryid + "/" + taskid + "/list"} // href={"/courses/" + coursesId + "/graduation/graduation_tasks/" + categoryid + "/" + taskid + "/list"}
onClick={()=>this.showfiles(discussMessage.title)} onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title} title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> : "" className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> : ""
} }
{ {
this.props.isStudent? <a this.props.isStudent? <a
onClick={()=>this.showfiles(discussMessage.title)} onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title} title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> :"" className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> :""
} }
@ -207,7 +214,7 @@ class Fileslistitem extends Component{
discussMessage.is_lock === true ? discussMessage.is_lock === true ?
<span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</span> <span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</span>
:<a :<a
onClick={()=>this.showfiles(discussMessage.title)} onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title} title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a>:"" className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a>:""
} }

@ -8,7 +8,7 @@ import Titlesearchsection from '../common/titleSearch/TitleSearchSection'
import ColorCountText from '../common/titleSearch/ColorCountText' import ColorCountText from '../common/titleSearch/ColorCountText'
import update from 'immutability-helper' import update from 'immutability-helper'
import { WordsBtn, ConditionToolTip, on, off ,trigger} from 'educoder' import { WordsBtn, ConditionToolTip, on, off ,trigger, sortDirections } from 'educoder'
import axios from 'axios' import axios from 'axios'
@ -63,6 +63,7 @@ function buildColumns(that) {
width: 120, width: 120,
key: 'name', key: 'name',
sorter: showSorter, sorter: showSorter,
sortDirections: sortDirections,
sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order, sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order,
render: (name, record) => { render: (name, record) => {
return <a href={`/users/${record.login}`} target="_blank" className="overflowHidden1" style={{ maxWidth: '110px'}} return <a href={`/users/${record.login}`} target="_blank" className="overflowHidden1" style={{ maxWidth: '110px'}}
@ -75,6 +76,7 @@ function buildColumns(that) {
sorter: showSorter, sorter: showSorter,
// 'ascend' | 'descend' // 'ascend' | 'descend'
defaultSortOrder: 'ascend', defaultSortOrder: 'ascend',
sortDirections: sortDirections,
sortOrder: sortedInfo.columnKey === 'role' && sortedInfo.order, sortOrder: sortedInfo.columnKey === 'role' && sortedInfo.order,
}] }]
@ -116,6 +118,7 @@ function buildColumns(that) {
title: '答辩组', title: '答辩组',
// width: 90, // width: 90,
sorter: showSorter, sorter: showSorter,
sortDirections: sortDirections,
key: 'graduation_group', key: 'graduation_group',
dataIndex: 'graduation_group', dataIndex: 'graduation_group',
sortOrder: sortedInfo.columnKey === 'graduation_group' && sortedInfo.order, sortOrder: sortedInfo.columnKey === 'graduation_group' && sortedInfo.order,

Loading…
Cancel
Save