|
|
|
@ -134,13 +134,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
|
|
|
|
|
|
|
|
|
|
user_id = video.user_id || video.video.user_id
|
|
|
|
|
tip_exception("您不是课堂管理员或者视频发布者,暂不能移动视频。") unless @user_course_identity < Course::PROFESSOR || user_id == current_user.id
|
|
|
|
|
|
|
|
|
|
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, "目录不存在")
|
|
|
|
|