Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
11afc7d63c
@ -0,0 +1,34 @@
|
||||
class CourseVideosController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :validate_params
|
||||
before_action :find_course, only: [:create]
|
||||
before_action :find_video, only: [:update]
|
||||
before_action :teacher_allowed
|
||||
|
||||
def create
|
||||
title = params[:name].strip
|
||||
link = params[:link].strip
|
||||
@course.course_videos.create!(title: title, link: link, is_link: 1, user_id: current_user.id)
|
||||
render_ok
|
||||
end
|
||||
|
||||
def update
|
||||
title = params[:name].strip
|
||||
link = params[:link].strip
|
||||
@video.update!(title: title, link: link)
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_params
|
||||
tip_exception("视频名称不能为空") if params[:name].blank?
|
||||
tip_exception("链接地址不能为空") if params[:link].blank?
|
||||
end
|
||||
|
||||
def find_video
|
||||
@video = CourseVideo.find params[:id]
|
||||
@course = @video.course
|
||||
end
|
||||
|
||||
end
|
@ -1,4 +1,7 @@
|
||||
class CourseVideo < ApplicationRecord
|
||||
belongs_to :course
|
||||
belongs_to :video
|
||||
belongs_to :video, optional: true
|
||||
belongs_to :user, optional: true
|
||||
|
||||
validates :title, length: { maximum: 60, too_long: "不能超过60个字符" }
|
||||
end
|
||||
|
@ -1,3 +1,22 @@
|
||||
json.count @count
|
||||
json.videos @videos, partial: 'users/videos/video', as: :video
|
||||
json.course_id @course.id
|
||||
|
||||
json.videos @videos do |video|
|
||||
if video.is_link
|
||||
json.(video, :id, :title, :link, :user_id)
|
||||
|
||||
user = video.user
|
||||
json.user_name user&.real_name
|
||||
json.user_img url_to_avatar(user)
|
||||
json.user_login user&.login
|
||||
else
|
||||
json.partial! 'users/videos/video', locals: { video: video.video }
|
||||
end
|
||||
end
|
||||
|
||||
json.course_id @course.id
|
||||
if @category.present?
|
||||
json.category_id @category.id
|
||||
json.category_name @category.name
|
||||
end
|
||||
json.course_module_id @video_module&.id
|
||||
json.has_category @video_module.course_second_categories.size > 0
|
@ -0,0 +1,5 @@
|
||||
class MigrateMemberAttendanceMode < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
CourseMemberAttendance.where(attendance_mode: 3).update_all(attendance_mode: 4)
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class AddLinkToCourseVideos < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :course_videos, :is_link, :boolean, default: 0
|
||||
add_column :course_videos, :title, :string
|
||||
add_column :course_videos, :link, :string
|
||||
add_column :course_videos, :user_id, :integer, index: true
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 147 KiB |
Loading…
Reference in new issue