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

dev_tpm_ui
杨树林 5 years ago
commit be6021a689

@ -61,7 +61,7 @@ class Admins::UsersController < Admins::BaseController
private private
def update_params def update_params
params.require(:user).permit(%i[lastname nickname gender identity technical_title student_id params.require(:user).permit(%i[lastname nickname gender identity technical_title student_id is_shixun_marker
mail phone location location_city school_id department_id admin business is_test mail phone location location_city school_id department_id admin business is_test
password professional_certification authentication]) password professional_certification authentication])
end end

@ -42,6 +42,12 @@ class ApplicationController < ActionController::Base
EduSetting.get(name) EduSetting.get(name)
end end
def shixun_marker
unless current_user.is_shixun_marker? || current_user.admin_or_business?
tip_exception(403, "..")
end
end
# 实训的访问权限 # 实训的访问权限
def shixun_access_allowed def shixun_access_allowed
if !current_user.shixun_permission(@shixun) if !current_user.shixun_permission(@shixun)

@ -1,4 +1,6 @@
class DepartmentsController < ApplicationController class DepartmentsController < ApplicationController
skip_before_action :check_sign
def for_option def for_option
render_ok(departments: current_school.departments.without_deleted.select(:id, :name).as_json) render_ok(departments: current_school.departments.without_deleted.select(:id, :name).as_json)
end end

@ -1,4 +1,5 @@
class SchoolsController < ApplicationController class SchoolsController < ApplicationController
skip_before_action :check_sign
def school_list def school_list
schools = School.all schools = School.all

@ -24,6 +24,7 @@ class ShixunsController < ApplicationController
before_action :portion_allowed, only: [:copy] before_action :portion_allowed, only: [:copy]
before_action :special_allowed, only: [:send_to_course, :search_user_courses] before_action :special_allowed, only: [:send_to_course, :search_user_courses]
before_action :shixun_marker, only: [:new, :create]
## 获取课程列表 ## 获取课程列表
def index def index
@ -1151,4 +1152,5 @@ private
end end
md5.hexdigest md5.hexdigest
end end
end end

@ -7,6 +7,8 @@ class SubjectsController < ApplicationController
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report, :search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
:up_member_position, :down_member_position, :update_team_title] :up_member_position, :down_member_position, :update_team_title]
before_action :require_admin, only: [:copy_subject] before_action :require_admin, only: [:copy_subject]
before_action :shixun_marker, only: [:new, :create, :add_shixun_to_stage]
include ApplicationHelper include ApplicationHelper
include SubjectsHelper include SubjectsHelper

@ -10,7 +10,7 @@ class Admins::IdentityAuths::AgreeApplyService < ApplicationService
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
apply.update!(status: 1) apply.update!(status: 1)
user.update!(authentication: true) user.update!(authentication: true)
user.update!(is_shixun_marker: true) if user.is_teacher?
RewardGradeService.call(user, container_id: user.id, container_type: 'Authentication', score: 500) RewardGradeService.call(user, container_id: user.id, container_type: 'Authentication', score: 500)
deal_tiding! deal_tiding!

@ -25,6 +25,7 @@ class Admins::UpdateUserService < ApplicationService
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
user.save! user.save!
user.user_extension.save! user.user_extension.save!
user.update!(is_shixun_marker: true) if user.is_certification_teacher
update_gitlab_password if params[:password].present? update_gitlab_password if params[:password].present?
end end
@ -36,7 +37,7 @@ class Admins::UpdateUserService < ApplicationService
def user_attributes def user_attributes
params.slice(*%i[lastname nickname mail phone admin business is_test params.slice(*%i[lastname nickname mail phone admin business is_test
professional_certification authentication]) professional_certification authentication is_shixun_marker])
end end
def user_extension_attributes def user_extension_attributes

@ -120,6 +120,7 @@
<div class="d-flex"> <div class="d-flex">
<%= f.input :professional_certification, as: :boolean, label: '职业认证', checked_value: 1, unchecked_value: 0 %> <%= f.input :professional_certification, as: :boolean, label: '职业认证', checked_value: 1, unchecked_value: 0 %>
<%= f.input :authentication, as: :boolean, label: '实名认证', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %> <%= f.input :authentication, as: :boolean, label: '实名认证', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
<%= f.input :is_shixun_marker, as: :boolean, label: '实训制作', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
</div> </div>
</div> </div>

@ -14,6 +14,7 @@ json.email @user.mail
json.profile_completed @user.profile_completed? json.profile_completed @user.profile_completed?
json.professional_certification @user.professional_certification json.professional_certification @user.professional_certification
json.main_site current_laboratory.main_site? json.main_site current_laboratory.main_site?
json.is_shixun_marker current_user.is_shixun_marker? || current_user.admin_or_business?
if @course if @course
json.course_identity @course_identity json.course_identity @course_identity
json.course_name @course.name json.course_name @course.name

@ -0,0 +1,9 @@
class AddIsShixunMarkerForUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :is_shixun_marker, :boolean, :default => false
User.joins(:user_extension)
.where(users: {professional_certification: 1}, user_extensions: {identity: 0})
.update_all(is_shixun_marker: 1)
end
end

@ -8,6 +8,8 @@ import { notification } from 'antd';
import './index.css'; import './index.css';
const $ = window.$; const $ = window.$;
const opens ="79e33abd4b6588941ab7622aed1e67e8"; const opens ="79e33abd4b6588941ab7622aed1e67e8";
let timestamp;
let checkSubmitFlg = false;
broadcastChannelOnmessage('refreshPage', () => { broadcastChannelOnmessage('refreshPage', () => {
window.location.reload() window.location.reload()
}) })
@ -19,7 +21,7 @@ function locationurl(list){
window.location.href=list window.location.href=list
} }
} }
let hashTimeout
// TODO 开发期多个身份切换 // TODO 开发期多个身份切换
let debugType ="" let debugType =""
@ -39,7 +41,29 @@ if (isDev) {
//ebugType="teacher"; //ebugType="teacher";
// 学生 // 学生
//debugType="student"; //debugType="student";
window.railsgettimes = function(proxy) {
if(timestamp&&checkSubmitFlg===false){
$.ajax({url:proxy,async:false,success:function(data){
if(data.status===0){
timestamp=data.message;
}
}})
checkSubmitFlg=true
window.setTimeout(function () {
checkSubmitFlg=false;
}, 3500);
}else if(checkSubmitFlg===false){
$.ajax({url:proxy,async:false,success:function(data){
if(data.status===0){
timestamp=data.message;
}
}})
checkSubmitFlg=true
window.setTimeout(function () {
checkSubmitFlg=false;
}, 3500);
}
}
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
initOnlineOfflineListener() initOnlineOfflineListener()
@ -62,17 +86,10 @@ export function initAxiosInterceptors(props) {
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制 // 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制
const requestMap = {}; const requestMap = {};
window.railsgettimes = function(proxy) {
$.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
if(data.status===0){
return data.message;
}
}});
}
window.setfalseInRequestMap = function(keyName) { window.setfalseInRequestMap = function(keyName) {
requestMap[keyName] = false; requestMap[keyName] = false;
} }
axios.interceptors.request.use( axios.interceptors.request.use(
config => { config => {
@ -102,8 +119,7 @@ export function initAxiosInterceptors(props) {
} }
if(`${config[0]}`!=`true`){ if(`${config[0]}`!=`true`){
if (window.location.port === "3007") { if (window.location.port === "3007") {
let timestamp=railsgettimes(proxy); railsgettimes(`${proxy}/api/main/first_stamp.json`);
console.log(timestamp)
let newopens=md5(opens+timestamp) let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`; config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
@ -113,6 +129,7 @@ export function initAxiosInterceptors(props) {
} }
} else { } else {
// 加api前缀 // 加api前缀
railsgettimes(`/api/main/first_stamp.json`);
config.url = url; config.url = url;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`; config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`;

@ -31,13 +31,15 @@ class ShixunsHome extends Component {
} }
} }
componentDidMount(){ componentDidMount(){
configShareForIndex() configShareForIndex()
const upsystem=`/users/system_update.json`; const upsystem=`/users/system_update.json`;
axios.get(upsystem).then((response)=>{ axios.get(upsystem).then((response)=>{
let updata=response.data; if(response.data){
this.setState({ let updata=response.data;
updata:updata this.setState({
}) updata:updata
})
}
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
}) })
@ -50,7 +52,7 @@ class ShixunsHome extends Component {
}) })
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error) // console.log(error)
}); });
} }

@ -1136,9 +1136,6 @@ submittojoinclass=(value)=>{
{/*<a href={this.props.Headertop===undefined?"":this.props.Headertop.course_url}>课堂</a>*/} {/*<a href={this.props.Headertop===undefined?"":this.props.Headertop.course_url}>课堂</a>*/}
<Link to={this.props.Headertop===undefined?"":'/courses'}>翻转课堂</Link> <Link to={this.props.Headertop===undefined?"":'/courses'}>翻转课堂</Link>
</li> </li>
{}
{console.log(activeShixuns)}
<li className={`${activeShixuns === true ? 'pr active' : 'pr'}`}> <li className={`${activeShixuns === true ? 'pr active' : 'pr'}`}>
<Link to="/shixuns">实训项目</Link> <Link to="/shixuns">实训项目</Link>
{/*<img src={getImageUrl("images/educoder/hot-h.png")} className="nav-img">*/} {/*<img src={getImageUrl("images/educoder/hot-h.png")} className="nav-img">*/}

Loading…
Cancel
Save