diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb index f4b49d4aa..fe2de4afe 100644 --- a/app/controllers/live_links_controller.rb +++ b/app/controllers/live_links_controller.rb @@ -2,7 +2,8 @@ class LiveLinksController < ApplicationController before_action :require_login before_action :find_course, only: [:index, :create] before_action :user_course_identity, :teacher_allowed, only: [:create] - before_action :edit_auth, only: [:edit, :update, :destroy] + before_action :edit_auth, only: [:edit, :update] + before_action :delete_auth, only: [:destroy] def index lives = @course.live_links @@ -58,6 +59,10 @@ class LiveLinksController < ApplicationController end def edit_auth + tip_exception(403, "无权限操作") unless current_user.id == current_live.user_id || current_user.admin_or_business? + end + + def delete_auth tip_exception(403, "无权限操作") unless current_user.id == current_live.user_id || current_user.admin? end end \ No newline at end of file diff --git a/app/models/live_link.rb b/app/models/live_link.rb index 5dcfaf3d3..52c1e3657 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -8,6 +8,10 @@ class LiveLink < ApplicationRecord validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } def op_auth? + user == User.current || User.current.admin_or_business? + end + + def delete_auth? user == User.current || User.current.admin? end end diff --git a/app/views/live_links/index.json.jbuilder b/app/views/live_links/index.json.jbuilder index e951f24bc..e497a068b 100644 --- a/app/views/live_links/index.json.jbuilder +++ b/app/views/live_links/index.json.jbuilder @@ -5,6 +5,7 @@ json.lives @lives do |live| json.author_login live.user.login json.author_img url_to_avatar(live.user) json.op_auth live.op_auth? + json.delete_auth live.delete_auth? json.created_at live.created_at.strftime('%Y-%m-%d') end json.my_live_id @my_live_id diff --git a/public/react/src/modules/courses/Video/Live.js b/public/react/src/modules/courses/Video/Live.js index f8c39a000..7d0e01d2b 100644 --- a/public/react/src/modules/courses/Video/Live.js +++ b/public/react/src/modules/courses/Video/Live.js @@ -1,9 +1,14 @@ import React,{ Component } from "react"; -import { Switch , Pagination } from 'antd'; -import { NoneData } from 'educoder'; +import { Pagination } from 'antd'; +// import { NoneData } from 'educoder'; import LiveItem from './LiveItem'; import './video.css'; + +import bilibili from './images/bilibili.png'; +import tencent from './images/tencent.png'; +import WeiBaiTong from './images/WeiBaiTong.png'; +import douyu from './images/douyu.jpg'; class Live extends Component{ render(){ @@ -11,10 +16,31 @@ class Live extends Component{ return(
+

EduCoder支持所有第三方直播平台,特别推荐:

+ { lives && lives.length > 0 ? -

{liveData && liveData.total_count} 个视频

+

{liveData && liveData.total_count} 个视频

{ lives.map((item,key)=>{ @@ -38,9 +64,10 @@ class Live extends Component{ } : -
- -
+ "" + //
+ // + //
}
) diff --git a/public/react/src/modules/courses/Video/LiveItem.js b/public/react/src/modules/courses/Video/LiveItem.js index 095a8fc62..a2fff5b98 100644 --- a/public/react/src/modules/courses/Video/LiveItem.js +++ b/public/react/src/modules/courses/Video/LiveItem.js @@ -72,13 +72,18 @@ class LiveItem extends Component{

创建时间:{item.created_at} - { - item.op_auth ? + - setLiveId(item.id)}>编辑 - this.deleteLive(item.id)}>删除 - :"" - } + { + item.op_auth ? + setLiveId(item.id)}>编辑:"" + } + { + item.delete_auth ? + this.deleteLive(item.id)}>删除 + :"" + } +

) diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index 897dd714a..a295a6fe5 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -137,10 +137,10 @@ class LiveNew extends Component{