From 5df061f9e19cedf298c776774d48be73093fa0e3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 19:02:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=88=B6=E4=BD=9C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 2 +- app/controllers/application_controller.rb | 6 ++++++ app/controllers/departments_controller.rb | 2 ++ app/controllers/schools_controller.rb | 1 + app/controllers/shixuns_controller.rb | 2 ++ app/controllers/subjects_controller.rb | 2 ++ .../admins/identity_auths/agree_apply_service.rb | 2 +- app/services/admins/update_user_service.rb | 3 ++- app/views/admins/users/edit.html.erb | 1 + app/views/users/get_user_info.json.jbuilder | 1 + .../20191230094544_add_is_shixun_marker_for_users.rb | 9 +++++++++ 11 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20191230094544_add_is_shixun_marker_for_users.rb diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index 9630394b4..b9a07ba1e 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -61,7 +61,7 @@ class Admins::UsersController < Admins::BaseController private 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 password professional_certification authentication]) end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 65c05ef2a..76922e316 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -44,6 +44,12 @@ class ApplicationController < ActionController::Base EduSetting.get(name) end + def shixun_marker + unless current_user.is_shixun_marker? + tip_exception(403, "..") + end + end + # 实训的访问权限 def shixun_access_allowed if !current_user.shixun_permission(@shixun) diff --git a/app/controllers/departments_controller.rb b/app/controllers/departments_controller.rb index 5e82b2c51..73cb19156 100644 --- a/app/controllers/departments_controller.rb +++ b/app/controllers/departments_controller.rb @@ -1,4 +1,6 @@ class DepartmentsController < ApplicationController + skip_before_action :check_sign + def for_option render_ok(departments: current_school.departments.without_deleted.select(:id, :name).as_json) end diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 99ca62b4c..dc9f6c091 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -1,4 +1,5 @@ class SchoolsController < ApplicationController + skip_before_action :check_sign def school_list schools = School.all diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8a752106c..4f2a19536 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -24,6 +24,7 @@ class ShixunsController < ApplicationController before_action :portion_allowed, only: [:copy] before_action :special_allowed, only: [:send_to_course, :search_user_courses] + before_action :shixun_marker, only: [:new, :create] ## 获取课程列表 def index @@ -1151,4 +1152,5 @@ private end md5.hexdigest end + end diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 2c1b5a810..917fca4b5 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -7,6 +7,8 @@ class SubjectsController < ApplicationController :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, :up_member_position, :down_member_position, :update_team_title] before_action :require_admin, only: [:copy_subject] + before_action :shixun_marker, only: [:new, :create] + include ApplicationHelper include SubjectsHelper diff --git a/app/services/admins/identity_auths/agree_apply_service.rb b/app/services/admins/identity_auths/agree_apply_service.rb index d75a6d7db..b5905dfef 100644 --- a/app/services/admins/identity_auths/agree_apply_service.rb +++ b/app/services/admins/identity_auths/agree_apply_service.rb @@ -10,7 +10,7 @@ class Admins::IdentityAuths::AgreeApplyService < ApplicationService ActiveRecord::Base.transaction do apply.update!(status: 1) 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) deal_tiding! diff --git a/app/services/admins/update_user_service.rb b/app/services/admins/update_user_service.rb index 41b5065d0..6b1c0c857 100644 --- a/app/services/admins/update_user_service.rb +++ b/app/services/admins/update_user_service.rb @@ -25,6 +25,7 @@ class Admins::UpdateUserService < ApplicationService ActiveRecord::Base.transaction do user.save! user.user_extension.save! + user.update!(is_shixun_marker: true) if user.is_certification_teacher update_gitlab_password if params[:password].present? end @@ -36,7 +37,7 @@ class Admins::UpdateUserService < ApplicationService def user_attributes params.slice(*%i[lastname nickname mail phone admin business is_test - professional_certification authentication]) + professional_certification authentication is_shixun_marker]) end def user_extension_attributes diff --git a/app/views/admins/users/edit.html.erb b/app/views/admins/users/edit.html.erb index abb003cbc..b1a8cbba1 100644 --- a/app/views/admins/users/edit.html.erb +++ b/app/views/admins/users/edit.html.erb @@ -120,6 +120,7 @@
<%= 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 :is_shixun_marker, as: :boolean, label: '实训制作', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index e80c8c215..eeb66f6eb 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -14,6 +14,7 @@ json.email @user.mail json.profile_completed @user.profile_completed? json.professional_certification @user.professional_certification json.main_site current_laboratory.main_site? +json.is_shixun_marker current_user.is_shixun_marker? || current_user.admin_or_business? if @course json.course_identity @course_identity json.course_name @course.name diff --git a/db/migrate/20191230094544_add_is_shixun_marker_for_users.rb b/db/migrate/20191230094544_add_is_shixun_marker_for_users.rb new file mode 100644 index 000000000..5a1eee4b1 --- /dev/null +++ b/db/migrate/20191230094544_add_is_shixun_marker_for_users.rb @@ -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 From 63d7759930e584ebf17afab5033a4b826da774ee Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 19:06:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=88=B6=E4=BD=9C?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 917fca4b5..7df9aae89 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -7,7 +7,7 @@ class SubjectsController < ApplicationController :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, :up_member_position, :down_member_position, :update_team_title] before_action :require_admin, only: [:copy_subject] - before_action :shixun_marker, only: [:new, :create] + before_action :shixun_marker, only: [:new, :create, :add_shixun_to_stage] include ApplicationHelper From 08fa196ba8f7759d32aa187bf61cc66a855b938b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 19:06:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6e55d1268..90151efca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -43,7 +43,7 @@ class ApplicationController < ActionController::Base end def shixun_marker - unless current_user.is_shixun_marker? + unless current_user.is_shixun_marker? || current_user.admin_or_business? tip_exception(403, "..") end end From 7c45fd9185d5e67c8c4c6a9f89fbe002ac8e943d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 30 Dec 2019 19:17:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 41 ++++++++++++++------ public/react/src/modules/home/shixunsHome.js | 14 ++++--- public/react/src/modules/tpm/NewHeader.js | 3 -- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 859b5f579..63be346bb 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -8,6 +8,8 @@ import { notification } from 'antd'; import './index.css'; const $ = window.$; const opens ="79e33abd4b6588941ab7622aed1e67e8"; +let timestamp; +let checkSubmitFlg = false; broadcastChannelOnmessage('refreshPage', () => { window.location.reload() }) @@ -19,7 +21,7 @@ function locationurl(list){ window.location.href=list } } -let hashTimeout + // TODO 开发期多个身份切换 let debugType ="" @@ -39,7 +41,29 @@ if (isDev) { //ebugType="teacher"; // 学生 //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; export function initAxiosInterceptors(props) { initOnlineOfflineListener() @@ -62,17 +86,10 @@ export function initAxiosInterceptors(props) { // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 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) { requestMap[keyName] = false; } + axios.interceptors.request.use( config => { @@ -102,8 +119,7 @@ export function initAxiosInterceptors(props) { } if(`${config[0]}`!=`true`){ if (window.location.port === "3007") { - let timestamp=railsgettimes(proxy); - console.log(timestamp) + railsgettimes(`${proxy}/api/main/first_stamp.json`); let newopens=md5(opens+timestamp) config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { @@ -113,6 +129,7 @@ export function initAxiosInterceptors(props) { } } else { // 加api前缀 + railsgettimes(`/api/main/first_stamp.json`); config.url = url; if (config.url.indexOf('?') == -1) { config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`; diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index a495a97c3..3e295344c 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -31,13 +31,15 @@ class ShixunsHome extends Component { } } componentDidMount(){ - configShareForIndex() + configShareForIndex() const upsystem=`/users/system_update.json`; axios.get(upsystem).then((response)=>{ - let updata=response.data; - this.setState({ - updata:updata - }) + if(response.data){ + let updata=response.data; + this.setState({ + updata:updata + }) + } }).catch((error)=>{ console.log(error); }) @@ -50,7 +52,7 @@ class ShixunsHome extends Component { }) } }).catch((error)=>{ - console.log(error) + // console.log(error) }); } diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 95813c28c..bdbef6c0d 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -1100,9 +1100,6 @@ submittojoinclass=(value)=>{ {/*课堂*/} 翻转课堂 - - {} - {console.log(activeShixuns)}
  • 实训项目 {/**/}