From fc965a3030b9929959a2d4c90ad16cb10bfb946f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 25 Jul 2019 11:34:14 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f5830adff..230e7f387 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -906,7 +906,6 @@ class CoursesController < ApplicationController CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id) - logger.info("#####################{course.id}") end end @@ -927,14 +926,18 @@ class CoursesController < ApplicationController role = course_message.content == 2 ? '7' : '9' # 7:老师 9:助教 ApplyTeacherRoleJoinCourseNotifyJob.perform_later(current_user.id, course.id, role) + teacher_role = 1 + message = "#{course_message.content == 2 ? '教师' : '助教'}申请已提交,请等待审核" end end end - if current_user.student_of_course?(course) || current_user.teacher_of_course?(course) - render json: { status: 0, message: "成功", course_id: course.id} + if teacher_role && current_user.student_of_course?(course) + render json: { status: 0, message: message, course_id: course.id} + elsif current_user.student_of_course?(course) + render json: { status: 0, message: "加入成功", course_id: course.id} else - normal_status("申请已提交,请等待审核") + normal_status(message) end rescue => e uid_logger(e.message) From a107be221c2a8f3135e60060ebff32ee693f1d1e Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 25 Jul 2019 14:02:02 +0800 Subject: [PATCH 2/9] delay 1 --- public/react/src/common/components/Cropper.js | 2 +- .../src/modules/courses/busyWork/UseBank.js | 2 +- .../user/account/ChangeHeaderPicModal.js | 21 ++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/public/react/src/common/components/Cropper.js b/public/react/src/common/components/Cropper.js index 632950434..3ce30a8b5 100644 --- a/public/react/src/common/components/Cropper.js +++ b/public/react/src/common/components/Cropper.js @@ -102,7 +102,7 @@ class Cropper extends Component { setTimeout(() => { const image = document.getElementById(this.props.imageId || '__image'); this.cropper = new window.Cropper(image, this.options); - }, 1000) + }, 1200) } renew = (image) => { diff --git a/public/react/src/modules/courses/busyWork/UseBank.js b/public/react/src/modules/courses/busyWork/UseBank.js index 671a09fff..ca65e74be 100644 --- a/public/react/src/modules/courses/busyWork/UseBank.js +++ b/public/react/src/modules/courses/busyWork/UseBank.js @@ -194,7 +194,7 @@ class UseBank extends Component{ display: -webkit-flex; } .setImgW .edu-nodata-img{ - width:218px !important; + width: 170px !important; } .bankwidth{ width:24% !important; diff --git a/public/react/src/modules/user/account/ChangeHeaderPicModal.js b/public/react/src/modules/user/account/ChangeHeaderPicModal.js index abb3d0e12..cef643094 100644 --- a/public/react/src/modules/user/account/ChangeHeaderPicModal.js +++ b/public/react/src/modules/user/account/ChangeHeaderPicModal.js @@ -105,11 +105,16 @@ class ChangeHeaderPicModal extends Component{ .then((response) => { // {"status":0,"message":"success","avatar_url":"avatars/User/15739"} if (response.data.status == 0) { - // this.props.getBasicInfo() - this.props.fetchUser() - // 头像更新后会触发AccountPage的DidUpdate,然后会调用getBasicInfo - this.props.showNotification && this.props.showNotification("修改头像成功") - this.setVisible(false) + // this.props.getBasicInfo() + // https://www.trustie.net/issues/22461 + if ( this.props.current_user.image_url.indexOf('avatars/User/b') != -1 + || this.props.current_user.image_url.indexOf('avatars/User/g') != -1 ) { + this.setTimeout(() => { + this.doAfterUpdated() + }, 1000) + } else { + this.doAfterUpdated(); + } } }) .catch(function (error) { @@ -117,6 +122,12 @@ class ChangeHeaderPicModal extends Component{ }); }); } + doAfterUpdated = () => { + this.props.fetchUser() + // 头像更新后会触发AccountPage的DidUpdate,然后会调用getBasicInfo + this.props.showNotification && this.props.showNotification("修改头像成功") + this.setVisible(false) + } render(){ const { course_lists } = this.state From 4f8585be428fb18f867413fef6b0fa804bcb5ee6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 25 Jul 2019 14:18:17 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E9=98=B6=E6=AE=B5=E5=90=8D=E7=A7=B0=E9=99=90=E5=88=B6?= =?UTF-8?q?60=E4=B8=AA=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../course_second_categories_controller.rb | 2 +- app/controllers/stages_controller.rb | 11 +++++++---- app/controllers/subjects_controller.rb | 2 +- app/models/stage.rb | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb index af368a8dc..e5c3366cd 100644 --- a/app/controllers/course_second_categories_controller.rb +++ b/app/controllers/course_second_categories_controller.rb @@ -8,7 +8,7 @@ class CourseSecondCategoriesController < ApplicationController tip_exception("毕设子目录不能重命名") if @category.category_type == "graduation" tip_exception("名称不能为空") if params[:name].blank? tip_exception("已存在同名子目录") if @course_module.course_second_categories.exists?(name: params[:name].strip) - @category.update_attributes(name: params[:name].strip) + @category.update_attributes!(name: params[:name].strip) normal_status(0, "更新成功") end diff --git a/app/controllers/stages_controller.rb b/app/controllers/stages_controller.rb index c62832365..d456c17e7 100644 --- a/app/controllers/stages_controller.rb +++ b/app/controllers/stages_controller.rb @@ -39,10 +39,13 @@ class StagesController < ApplicationController def update ActiveRecord::Base.transaction do begin - @stage.update_attributes(stage_params) - @stage.stage_shixuns.destroy_all + @stage.update_attributes!(stage_params) unless params[:shixun_id].blank? - params[:shixun_id].each do |shixun_id| + new_shixun_ids = params[:shixun_id] - @stage.stage_shixuns.pluck(:shixun_id) + delete_shixun_ids = @stage.stage_shixuns.pluck(:shixun_id) - params[:shixun_id] + @stage.stage_shixuns.where(shixun_id: delete_shixun_ids).destroy_all + + new_shixun_ids.each do |shixun_id| shixun = Shixun.where(id: shixun_id).first @stage.stage_shixuns.create!(subject_id: @subject.id, shixun_id: shixun.id, position: @stage.stage_shixuns.count + 1) if shixun.present? end @@ -50,7 +53,7 @@ class StagesController < ApplicationController @subject.update_attributes(updated_at: Time.now) rescue Exception => e uid_logger_error(e.message) - tip_exception("章节更新失败") + tip_exception(e.message) raise ActiveRecord::Rollback end end diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index cc0e06a38..5cbb2a462 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -207,7 +207,7 @@ class SubjectsController < ApplicationController end rescue Exception => e uid_logger(e.message) - tip_exception("发送失败") + tip_exception(e.message) raise ActiveRecord::Rollback end end diff --git a/app/models/stage.rb b/app/models/stage.rb index d255cddeb..db7b5c0b3 100644 --- a/app/models/stage.rb +++ b/app/models/stage.rb @@ -6,6 +6,6 @@ class Stage < ApplicationRecord has_many :stage_shixuns, -> { order("stage_shixuns.position ASC") }, dependent: :destroy has_many :shixuns, :through => :stage_shixuns - validates :name, length: { maximum: 30 } + validates :name, length: { maximum: 60 } validates :description, length: { maximum: 300 } end From b0b056ebc35f2fed4015945baadac228f79fa941 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 25 Jul 2019 14:23:02 +0800 Subject: [PATCH 4/9] stage update --- app/controllers/stages_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/controllers/stages_controller.rb b/app/controllers/stages_controller.rb index d456c17e7..3967554aa 100644 --- a/app/controllers/stages_controller.rb +++ b/app/controllers/stages_controller.rb @@ -40,12 +40,9 @@ class StagesController < ApplicationController ActiveRecord::Base.transaction do begin @stage.update_attributes!(stage_params) + @stage.stage_shixuns.destroy_all unless params[:shixun_id].blank? - new_shixun_ids = params[:shixun_id] - @stage.stage_shixuns.pluck(:shixun_id) - delete_shixun_ids = @stage.stage_shixuns.pluck(:shixun_id) - params[:shixun_id] - @stage.stage_shixuns.where(shixun_id: delete_shixun_ids).destroy_all - - new_shixun_ids.each do |shixun_id| + params[:shixun_id].each do |shixun_id| shixun = Shixun.where(id: shixun_id).first @stage.stage_shixuns.create!(subject_id: @subject.id, shixun_id: shixun.id, position: @stage.stage_shixuns.count + 1) if shixun.present? end From 5bfb41ad37c3ca0dcb7a652eb6496d9b8c69cfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 25 Jul 2019 14:34:46 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesDetail/CoursesLeftNav.js | 4 +- .../courses/coursesPublic/AddcoursesNav.js | 148 +++++++++--------- .../courses/coursesPublic/ModalsRename.js | 124 +++++++-------- public/react/src/modules/paths/Index.js | 108 +++++++------ .../modules/paths/PathDetail/DetailCards.js | 20 ++- .../paths/PathDetail/DetailCardsEditAndAdd.js | 2 +- .../PathDetail/DetailCardsEditAndEdit.js | 2 +- .../paths/PathDetail/PathDetailIndex.js | 6 + 8 files changed, 220 insertions(+), 194 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 2a395200c..707c4ba9b 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -408,7 +408,7 @@ class Coursesleftnav extends Component{ this.setState({ Navmodalname:id===2?"新建分班":"添加目录", Navtitles:id===2?"分班名称":"目录名称", - Navplaceholder:id===2?"示例:分班(最佳4个字符)":"示例:第一阶段(最佳4个字符)", + Navplaceholder:"请输入名称,最大限制60个字符", Navmodalnametype:true, Navmodaltypename:id, setnavid:setnavid, @@ -419,7 +419,7 @@ class Coursesleftnav extends Component{ this.setState({ Navmodalname:id===5?"分班重命名":"目录重命名", Navtitles:id===5?"分班名称":"目录名称", - Navplaceholder:id===5?"示例:分班(最佳4个字符)":"示例:第一阶段(最佳4个字符)", + Navplaceholder:"请输入名称,最大限制60个字符", Navmodalnametype:true, Navmodaltypename:id, setnavid:setnavid, diff --git a/public/react/src/modules/courses/coursesPublic/AddcoursesNav.js b/public/react/src/modules/courses/coursesPublic/AddcoursesNav.js index 74c03808a..756ae62a6 100644 --- a/public/react/src/modules/courses/coursesPublic/AddcoursesNav.js +++ b/public/react/src/modules/courses/coursesPublic/AddcoursesNav.js @@ -1,74 +1,74 @@ -import React,{ Component } from "react"; -import { Modal,Checkbox,Input,Select} from "antd"; -const Option = Select.Option; - -class AddcoursesNav extends Component{ - constructor(props){ - super(props); - this.state={ - StudentList_value:"" - } - } - - - - render(){ - // let {StudentList_value}=this.state; - // let {child}=this.props; - // - return( -