From ffb5939a088cb09c5950ffcc958b3ddbbc08eda8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 15:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/live_link.rb | 15 +-------------- app/views/live_links/index.json.jbuilder | 3 +-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/models/live_link.rb b/app/models/live_link.rb index 27963a0bb..3cc17e6b3 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -7,23 +7,10 @@ class LiveLink < ApplicationRecord validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" } validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } validates :course_name, presence: true - validates :platform, presence: true, inclusion: {in: %W(tencent douyu bilibili vbt)} + validates :platform, presence: true # validates :live_time, presence: true validates :duration, numericality: { only_integer: true, greater_than: 0}, allow_blank: true - def platform_name - case platform - when "tencent" - "腾讯课堂" - when "douyu" - "斗鱼直播" - when "vbt" - "威佰通" - else - platform - end - end - def op_auth? user == User.current || User.current.admin_or_business? end diff --git a/app/views/live_links/index.json.jbuilder b/app/views/live_links/index.json.jbuilder index 419fb49bb..95891fc8a 100644 --- a/app/views/live_links/index.json.jbuilder +++ b/app/views/live_links/index.json.jbuilder @@ -1,5 +1,5 @@ json.lives @lives do |live| - json.(live, :id, :description, :on_status, :duration, :course_name) + json.(live, :id, :description, :on_status, :duration, :course_name, :platform) json.url live.on_status ? live.url : "" json.author_name live.user.show_real_name json.author_login live.user.login @@ -7,7 +7,6 @@ json.lives @lives do |live| json.op_auth live.op_auth? json.delete_auth live.delete_auth? json.live_time live.live_time&.strftime('%Y-%m-%d %H:%M:%S') - json.platform live.platform_name end json.my_live_id @my_live_id json.total_count @total_count \ No newline at end of file