diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2e94e435d..de0603868 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -133,13 +133,17 @@ class CoursesController < ApplicationController # 视频移动到目录 def move_to_category + tip_exception("请选择要移动的目录") if params[:new_category_id].blank? category = @course.course_second_categories.find_by(id: params[:new_category_id]) if params[:new_category_id].to_i == 0 || category.present? - videos = @course.course_videos.where(video_id: params[:video_ids]).or(@course.course_videos.where(id: params[:video_ids])) + video = @course.course_videos.where(video_id: params[:video_ids]).or(@course.course_videos.where(id: params[:video_ids])).first + + tip_exception("您不是课堂管理员或者视频发布者,暂不能移动视频。") unless @user_course_identity < Course::PROFESSOR || + video.user_id == current_user.id || current_user.admin_or_business? - videos.update_all(course_second_category_id: params[:new_category_id]) + video.update!(course_second_category_id: params[:new_category_id]) normal_status(0, "操作成功") else normal_status(-1, "目录不存在")