diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06adc676d..3ec8ad0f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -299,7 +299,7 @@ class ApplicationController < ActionController::Base # and starts a session if needed def find_current_user uid_logger("user setup start: session[:user_id] is #{session[:user_id]}") - uid_logger("0000000000000user setup start: session[:user_id] is #{session[:"#{default_yun_session}"]}") + uid_logger("0000000000000user setup start: default_yun_session is #{default_yun_session}, session[:current_user_id] is #{session[:"#{default_yun_session}"]}") current_domain_session = session[:"#{default_yun_session}"] if current_domain_session # existing session diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index ecb478388..e2989219b 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -6,7 +6,6 @@ module LaboratoryHelper helper_method :current_laboratory helper_method :default_setting - helper_method :default_yun_session end def current_laboratory @@ -26,7 +25,7 @@ module LaboratoryHelper end def default_yun_session - @_default_yun_session = "#{request.subdomain.split('.').first}_user_id" - # @_default_yun_session = "#{current_laboratory.try(:identifier).split('.').first}_user_id" + laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)) + @_default_yun_session = "#{laboratory.try(:identifier).split('.').first}_user_id" end end \ No newline at end of file diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index ec4656e3b..ede7ff071 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -47,12 +47,16 @@ module LoginHelper User.current.delete_session_token(session[:tk]) self.logged_user = nil end + # 云上实验室退出清理当前session + laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)) + default_yun_session = "#{laboratory.try(:identifier).split('.').first}_user_id" + # end session[:"#{default_yun_session}"] = nil end # Sets the logged in user def logged_user=(user) - reset_session + # reset_session if user && user.is_a?(User) User.current = user start_user_session(user) diff --git a/app/models/user.rb b/app/models/user.rb index ec0640700..27c9e03ae 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -329,7 +329,7 @@ class User < ApplicationRecord # 实训路径:合作者、admin def manager_of_subject?(subject) - subject.subject_members.exists?(user_id: id, role: [1,2]) || admin? + subject.subject_members.exists?(user_id: id, role: [1,2]) || admin? || business? end # 实训管理员:实训合作者、admin diff --git a/public/react/src/modules/paths/PathDetail/Addshixuns.js b/public/react/src/modules/paths/PathDetail/Addshixuns.js index 6bf60080a..0c1a194e5 100644 --- a/public/react/src/modules/paths/PathDetail/Addshixuns.js +++ b/public/react/src/modules/paths/PathDetail/Addshixuns.js @@ -30,8 +30,22 @@ class Addshixuns extends Component { this.props.modalCancel() } + //判断是否为空 + getshixunname( str ){ + if ( str == "" ) return true; + var regu = "^[ ]+$"; + var re = new RegExp(regu); + return re.test(str); + } + modalSave=()=>{ let {shixunname}=this.state; + if(this.getshixunname(shixunname)===true){ + this.setState({ + shixunzero:true + }) + return + } if(shixunname===undefined||shixunname.length===0){ this.setState({ shixunzero:true diff --git a/public/react/src/modules/paths/PathDetail/DetailCards.js b/public/react/src/modules/paths/PathDetail/DetailCards.js index 6bc972a03..fdcbb0297 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCards.js +++ b/public/react/src/modules/paths/PathDetail/DetailCards.js @@ -420,7 +420,35 @@ class DetailCards extends Component{ { idsum===key&&pathCardsedittype===true?'': - this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_statistics===true? + this.props.detailInfoList===undefined?"": + this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + + + { editbuttomtype===true?'': + this.pathCardsedit(key, item.stage_id)}> + + + } + + { + pathCardsList.length=== key+1?"":this.operations(item.down_path)}> + + + + + } + + + {key===0?"": + this.operations(item.up_path)}> + + + + } + + : + this.props.detailInfoList.allow_statistics===true? { editbuttomtype===true?'': @@ -453,7 +481,14 @@ class DetailCards extends Component{ { idsum === key && pathCardsedittype === true ? - this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_statistics===true? + this.props.detailInfoList===undefined?"": + this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + this.delectpathCardsedit(item.stage_id)}> + + + + : + this.props.detailInfoList.allow_statistics===true? this.delectpathCardsedit(item.stage_id)}> @@ -471,8 +506,36 @@ class DetailCards extends Component{
- { - item.shixuns_list && item.shixuns_list.map((line,index)=>{ + {this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + item.shixuns_list && item.shixuns_list.map((line,index)=>{ + return( +
this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}> + +
  • + + + { + line.complete_status === 1 ? + : + } + + + {key+1}-{index+1}  {line.shixun_name} + + +
  • + + +
  • + { + showparagraphkey===key&&showparagraphindex===index?
    + 查看详情 +
    :"" + } +
  • + +
    ) + }):item.shixuns_list && item.shixuns_list.map((line,index)=>{ return(
    this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}>