From 48e85cb07866fd733d862b91d71293b216b12f25 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 15:29:49 +0800 Subject: [PATCH 1/9] =?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/views/examination_banks/show.json.jbuilder | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/examination_banks/show.json.jbuilder b/app/views/examination_banks/show.json.jbuilder index 2a2da9af9..187e89cc2 100644 --- a/app/views/examination_banks/show.json.jbuilder +++ b/app/views/examination_banks/show.json.jbuilder @@ -40,7 +40,9 @@ json.exam do json.all_questions_count @items.size json.discipline do - json.(@exam.sub_discipline&.discipline, :id, :name) + if @exam.sub_discipline&.discipline.present? + json.(@exam.sub_discipline&.discipline, :id, :name) + end end json.sub_discipline do json.(@exam.sub_discipline, :id, :name) From 7e6bee1ec326da4f6973e3b8b9d5e2c158273c52 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 15:34:25 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=BA=93=E7=9A=84?= =?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/views/examination_banks/show.json.jbuilder | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/examination_banks/show.json.jbuilder b/app/views/examination_banks/show.json.jbuilder index 187e89cc2..eed1b2407 100644 --- a/app/views/examination_banks/show.json.jbuilder +++ b/app/views/examination_banks/show.json.jbuilder @@ -45,7 +45,9 @@ json.exam do end end json.sub_discipline do - json.(@exam.sub_discipline, :id, :name) + if @exam.sub_discipline.present? + json.(@exam.sub_discipline, :id, :name) + end end json.tag_disciplines @exam.tag_disciplines do |tag| json.(tag, :id, :name) 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 3/9] =?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 From 1c99de4c8453bcee246d432409b4a28ef7553447 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 13 Feb 2020 16:13:45 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=BF=85=E9=80=89=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/Video/LiveNew.js | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index d505f052d..6d4197171 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Modal , Form , Input , Spin , Select , DatePicker , InputNumber } from 'antd'; +import { Modal , Form , Input , Spin , Select , AutoComplete , DatePicker , InputNumber } from 'antd'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import moment from 'moment'; import { handleDateString } from 'educoder'; @@ -9,6 +9,7 @@ import axios from 'axios'; const { TextArea } = Input; const { Option } = Select; +const array=['腾讯课堂','B站','斗鱼','威佰通'] function range(start, end) { const result = []; @@ -34,17 +35,14 @@ class LiveNew extends Component{ this.state={ isSpining:false, beginTime:undefined, - beginTimeFlag:false, } } componentDidMount=()=>{ - console.log("1",this.props.liveId) this.checkType(); } componentDidUpdate=(prevState)=>{ - console.log("2",prevState.liveId); if(prevState && prevState.liveId !== this.props.liveId){ this.setState({ isSpining:true @@ -55,7 +53,6 @@ class LiveNew extends Component{ checkType=()=>{ const { liveId } = this.props; - console.log("3",this.props.liveId); this.clearAll(); if(liveId){ const url =`/live_links/${liveId}/edit.json`; @@ -64,7 +61,7 @@ class LiveNew extends Component{ this.props.form.setFieldsValue({ url:result.data.url, description:result.data.description, - platform:result.data.platform || "tencent", + platform:result.data.platform || "腾讯课堂", duration:result.data.duration, course_name:result.data.course_name }) @@ -80,15 +77,12 @@ class LiveNew extends Component{ } handleSubmit=()=>{ + this.setState({ + isSpining:true + }) this.props.form.validateFields((err, values) => { if(!err){ - const { beginTime } = this.state; - if(!beginTime){ - this.setState({ - beginTimeFlag:true - }) - return; - } + console.log(values); const { liveId } = this.props; if(liveId){ // 修改 @@ -108,6 +102,9 @@ class LiveNew extends Component{ live_time:beginTime }).then(result=>{ if(result){ + this.setState({ + isSpining:false + }) this.props.showNotification("修改成功!"); const { setliveVisibel } = this.props; setliveVisibel && setliveVisibel(false,true); @@ -127,6 +124,9 @@ class LiveNew extends Component{ live_time:beginTime }).then(result=>{ if(result){ + this.setState({ + isSpining:false + }) this.props.showNotification("添加成功!"); const { setliveVisibel } = this.props; setliveVisibel && setliveVisibel(false,true); @@ -156,7 +156,7 @@ class LiveNew extends Component{ clearAll=()=>{ this.props.form.setFieldsValue({ course_name:undefined, - platform:"tencent", + platform:"腾讯课堂", url:undefined, description:undefined, duration:undefined @@ -173,10 +173,15 @@ class LiveNew extends Component{ } render(){ - const { isSpining , beginTime , beginTimeFlag } = this.state; + const { isSpining , beginTime } = this.state; const {getFieldDecorator} = this.props.form; const { visible } = this.props; + const dataSource = array.map((item,key)=>{ + return( + + ) + }) return( - - - - + + )} {getFieldDecorator('url', { - rules: [{required: true, message: "请输入第三方直播链接"}], + rules: [], })( )}
-

*开播时间

+

开播时间

-

- { - beginTimeFlag && 请选择开播时间 - } -

{getFieldDecorator('duration', { From a5ed9c1f192ac8740ae30aa0f837c37a964f0119 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 16:27:50 +0800 Subject: [PATCH 5/9] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/live_link.rb b/app/models/live_link.rb index 3cc17e6b3..9b59eb8c1 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -4,7 +4,7 @@ class LiveLink < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy - validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" } + # validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" } validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } validates :course_name, presence: true validates :platform, presence: true From 15564639ecb9559f89ff8c579a800e6dae9f1bab Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 13 Feb 2020 16:35:26 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E7=9B=B4=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/Video/LiveNew.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index 6d4197171..589709b24 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -102,14 +102,17 @@ class LiveNew extends Component{ live_time:beginTime }).then(result=>{ if(result){ - this.setState({ - isSpining:false - }) this.props.showNotification("修改成功!"); const { setliveVisibel } = this.props; setliveVisibel && setliveVisibel(false,true); } + this.setState({ + isSpining:false + }) }).catch(error=>{ + this.setState({ + isSpining:false + }) console.log(error); }) } @@ -124,14 +127,17 @@ class LiveNew extends Component{ live_time:beginTime }).then(result=>{ if(result){ - this.setState({ - isSpining:false - }) this.props.showNotification("添加成功!"); const { setliveVisibel } = this.props; setliveVisibel && setliveVisibel(false,true); } + this.setState({ + isSpining:false + }) }).catch(error=>{ + this.setState({ + isSpining:false + }) console.log(error); }) } From 2848643c8d9f1aae3e41906c1844039b783db1c7 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 13 Feb 2020 16:40:52 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Video/LiveNew.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index 589709b24..15c0a8403 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -77,12 +77,11 @@ class LiveNew extends Component{ } handleSubmit=()=>{ - this.setState({ - isSpining:true - }) this.props.form.validateFields((err, values) => { if(!err){ - console.log(values); + this.setState({ + isSpining:true + }) const { liveId } = this.props; if(liveId){ // 修改 From 7c3dc6e023dc431cf08c55386c14a947472303de Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Thu, 13 Feb 2020 17:15:15 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/Video/LiveItem.js | 2 +- .../react/src/modules/courses/Video/LiveNew.js | 8 ++++---- .../src/modules/courses/Video/VideoIndex.js | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/courses/Video/LiveItem.js b/public/react/src/modules/courses/Video/LiveItem.js index 0bee79fe2..8e70e2972 100644 --- a/public/react/src/modules/courses/Video/LiveItem.js +++ b/public/react/src/modules/courses/Video/LiveItem.js @@ -44,7 +44,7 @@ class LiveItem extends Component{

{item.description}

{ - item.on_status? + (item.on_status && item.url)? 进入 : 进入 diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index 15c0a8403..e9d9bf9b1 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -191,7 +191,7 @@ class LiveNew extends Component{ {getFieldDecorator('course_name', { - rules: [{required: true, message: "请输入课程名字"}], + rules: [{required: true, message: "请输入课程名称"}], })( - + )} @@ -230,7 +230,7 @@ class LiveNew extends Component{ { ` body{ - width: 100%!important; + width: calc(100% - 7px)!important; overflow: hidden!important; } - `}:"" + .-task-sidebar{ + right:44px!important + } + `}: + }
From cb480355057e501513b8261c4fda7813301ed755 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 17:52:29 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=89=80=E5=9C=A8=E5=9C=B0=E4=B8=AD=E5=8C=85=E5=90=AB=E7=9C=81?= =?UTF-8?q?=E3=80=81=E5=B8=82=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20200213094050_migrate_user_location.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20200213094050_migrate_user_location.rb diff --git a/db/migrate/20200213094050_migrate_user_location.rb b/db/migrate/20200213094050_migrate_user_location.rb new file mode 100644 index 000000000..a15d299a1 --- /dev/null +++ b/db/migrate/20200213094050_migrate_user_location.rb @@ -0,0 +1,11 @@ +class MigrateUserLocation < ActiveRecord::Migration[5.2] + def change + UserExtension.where("location like '%省'").each do |ue| + ue.update_column("location", ue.location.chop) + end + + UserExtension.where("location_city like '%市'").each do |ue| + ue.update_column("location_city", ue.location_city.chop) + end + end +end