From a91d610d6564e3b502bbf6962edb9d37529cf057 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:16:38 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 5 +++++ app/views/attachments/_attachment.json.jbuilder | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c1fa48be8..54b1725f9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -289,6 +289,11 @@ class FilesController < ApplicationController @old_attachment.save! @new_attachment.delete end + if params[:name].present? && params[:link].present? + tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60 + @old_attachment.filename = params[:name].strip + @old_attachment.link = params[:link].strip + end @old_attachment.is_public = is_public == true && @course.is_public == 1 ? 1 : 0 @old_attachment.is_publish = @atta_is_publish @old_attachment.delay_publish = @atta_delay_publish diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b30869d57..c87f8372e 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -1,5 +1,6 @@ json.id attachment.id json.title attachment.title +json.link attachment.link json.is_public attachment.publiced? # json.is_lock attachment.locked?(@is_member) json.is_lock !attachment.publiced? @@ -15,4 +16,4 @@ json.created_on attachment.created_on json.content_type attachment.content_type json.is_pdf attachment.is_pdf? json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) -json.play_url attachment_show_users_path(file_name: local_path(attachment)) +json.play_url attachment.link.present? ? nil : attachment_show_users_path(file_name: local_path(attachment)) From e90e3f3f8b57a822dbde4324213ed47b4bfb1730 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 21:21:24 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 7bf1b6c1b..4eae691f4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -195,7 +195,7 @@ Rails.application.routes.draw do resource :unread_message_info, only: [:show] # 视频 - resources :videos, only: [:index, :update] do + resources :videos, only: [:index, :update, :destroy] do collection do get :review post :batch_publish From 32466bf3187758f674a5d3407dba97f112a2af1a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:40:46 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 9 +++++++-- config/routes.rb | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 54b1725f9..427545716 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -2,13 +2,13 @@ class FilesController < ApplicationController include MessagesHelper before_action :require_login, :check_auth, except: %i[index] - before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project] + before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project update_visits] before_action :find_ids, only: %i[bulk_delete bulk_send bulk_move bulk_public bulk_publish] before_action :file_validate_sort_type, only: :index before_action :validate_send_message_to_course_params, only: :bulk_send before_action :set_pagination, only: %i[index public_with_course_and_project mine_with_course_and_project] before_action :validate_upload_params, only: %i[import] - before_action :find_file, only: %i[show setting update] + before_action :find_file, only: %i[show setting update update_visits] before_action :publish_params, only: %i[upload import update] SORT_TYPE = %w[created_on downloads quotes] @@ -355,6 +355,11 @@ class FilesController < ApplicationController end end + def update_visits + @file.increment!(:downloads) + render_ok + end + private def find_file @file = Attachment.find params[:id] diff --git a/config/routes.rb b/config/routes.rb index 7bf1b6c1b..3cda05f0d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -464,6 +464,7 @@ Rails.application.routes.draw do end member do get :histories + post :update_visits end end From 59e2321c6686308361179abe09553bb44b880e23 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 22:00:48 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/videos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 645c25362..3aa8e106d 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -54,7 +54,7 @@ class Users::VideosController < Users::BaseController end def destroy - video = observed_user.videos.find_by(id: params[:video_id]) + video = Video.find_by(id: params[:video_id]) render_forbidden unless video.user_id != observed_user.id || !current_user.admin_or_business? return render_not_found if video.blank? return render_error('该状态下不能删除视频') unless video.pending? From aa2ceb4817025c7947b1339a8ebeb4173587d35d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 22:02:58 +0800 Subject: [PATCH 05/16] 1 --- app/controllers/users/videos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 3aa8e106d..558ea1f21 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -54,7 +54,7 @@ class Users::VideosController < Users::BaseController end def destroy - video = Video.find_by(id: params[:video_id]) + video = Video.find_by(id: params[:id]) render_forbidden unless video.user_id != observed_user.id || !current_user.admin_or_business? return render_not_found if video.blank? return render_error('该状态下不能删除视频') unless video.pending? From cc9dac4b67b4f27adfb87ff40431e14afdf4369d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:05:57 +0800 Subject: [PATCH 06/16] tiaoz --- app/controllers/application_controller.rb | 2 +- .../weapps/attendances_controller.rb | 10 +++++----- .../course_member_attendances_controller.rb | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..fa4648852 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 3117 end diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 57e1e10df..19823d42b 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -62,11 +62,11 @@ class Weapps::AttendancesController < ApplicationController where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'") @history_count = @history_attendances.size - # 当前签到如果存在快捷签到,则直接签到 - quick_attendances = @current_attendances.where(mode: "QUICK") - if quick_attendances.present? - student_direct_attendance quick_attendances, member - end + # 当前签到如果存在快捷签到,则直接签到(不在这里处理) + # quick_attendances = @current_attendances.where(mode: "QUICK") + # if quick_attendances.present? + # student_direct_attendance quick_attendances, member + # end student_attendance_ids = @history_attendances.pluck(:id) student_attendance_ids += @current_attendances.present? ? @current_attendances.pluck(:id) : [] diff --git a/app/controllers/weapps/course_member_attendances_controller.rb b/app/controllers/weapps/course_member_attendances_controller.rb index 7e315fc85..5e92d5928 100644 --- a/app/controllers/weapps/course_member_attendances_controller.rb +++ b/app/controllers/weapps/course_member_attendances_controller.rb @@ -28,19 +28,24 @@ class Weapps::CourseMemberAttendancesController < ApplicationController end def create - tip_exception("签到码不能为空") if params[:code].blank? - tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE"].include?(params[:attendance_mode]) + tip_exception("签到码不能为空") if params[:attendance_mode] != "QUICK" && params[:code].blank? + tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE", "QUICK"].include?(params[:attendance_mode]) - attendance = CourseAttendance.find_by(attendance_code: params[:code]) - tip_exception("签到码输入有误") if attendance.blank? || attendance.course.blank? + if params[:attendance_mode] == "QUICK" + attendance = CourseAttendance.find_by(id: params[:attendance_id]) + else + attendance = CourseAttendance.find_by(attendance_code: params[:code]) + end + tip_exception("该签到不存在") if attendance.blank? || attendance.course.blank? member = attendance.course.students.find_by(user_id: current_user.id) - tip_exception("签到码输入有误") if member.blank? + tip_exception("该签到不存在") if member.blank? tip_exception("不在签到时间内") unless attendance.current_attendance? - tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] == "QRCODE" - tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] == "NUMBER" + tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] != "NUMBER" + tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] != "QRCODE" + tip_exception("只支持快捷签到") if attendance.mode == "QUICK" && params[:attendance_mode] != "QUICK" current_attendance = attendance.course_member_attendances.find_by(user_id: current_user.id) if current_attendance.present? From 5177a91b13234e91f4c3db26ae6243565d7e9428 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 22:06:06 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/videos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 558ea1f21..fdd7e0c76 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -55,7 +55,7 @@ class Users::VideosController < Users::BaseController def destroy video = Video.find_by(id: params[:id]) - render_forbidden unless video.user_id != observed_user.id || !current_user.admin_or_business? + return render_forbidden unless video.user_id == current_user.id || current_user.admin_or_business? return render_not_found if video.blank? return render_error('该状态下不能删除视频') unless video.pending? From c7dad0d3ef8acb1f0d3a6458a785d92ca43bce77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 9 Mar 2020 20:17:39 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Index.js | 4 +- .../src/modules/courses/Resource/index.js | 62 ++- .../courses/coursesPublic/sendResources.js | 508 ++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 public/react/src/modules/courses/coursesPublic/sendResources.js diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index fb4afd436..8a21e76da 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -10,7 +10,7 @@ import { CNotificationHOC } from './common/CNotificationHOC' import {ImageLayerOfCommentHOC} from '../page/layers/ImageLayerOfCommentHOC' import "./css/Courses.css" //引入对应跳转的组件 - +//里面有资源 const ListPageIndex = Loadable({ loader: () => import('./ListPageIndex'), loading:Loading, @@ -964,4 +964,4 @@ class CoursesIndex extends Component{ } } -export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); \ No newline at end of file +export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 8187cd5af..250d643dc 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -6,6 +6,8 @@ import Modals from '../../modals/Modals'; import Sendtofilesmodal from "../coursesPublic/SendToFilesModal"; import Selectresource from "../coursesPublic/SelectResource"; import Sendresource from "../coursesPublic/sendResource"; +import SendResources from "../coursesPublic/sendResources"; + import Selectsetting from "../coursesPublic/SelectSetting"; import HomeworkModal from "../coursesPublic/HomeworkModal"; import Fileslistitem from './Fileslistitem'; @@ -34,7 +36,9 @@ class Fileslists extends Component{ name:"", sendTotype:false, Accessoryvisible:false, - discussMessageid:undefined, + Addanexternallink:false, + Exterchainname:"添加外链", + discussMessageid:undefined, course_modules:undefined, has_course_groups:false, course_is_public:undefined, @@ -570,6 +574,35 @@ class Fileslists extends Component{ }) } + //添加外链资源设置 + sendResourcessls = (ints,bool) => { + if(bool===true){ + + if(ints===1){ + this.setState({ + Addanexternallink:true, + Exterchainname:"添加外链" + }) + + }else{ + this.setState({ + Addanexternallink:true, + Exterchainname:"资源设置" + }) + + } + + + }else{ + this.setState({ + Addanexternallink:false, + }) + } + + } + + + Cancelvisible=()=>{ @@ -729,7 +762,9 @@ class Fileslists extends Component{ course_is_public, filesId, child, - sort + sort, + Addanexternallink, + Exterchainname } = this.state; let category_id= this.props.match.params.category_id; @@ -781,7 +816,7 @@ class Fileslists extends Component{ loadtype={Loadtype} />:""} { - shixunmodal===true||Accessoryvisible===true||Settingtype===true? + +

+ 资源名称: + + + +

+ { + resourcesnamebool? +

请输入资源名称

+ : + "" + } +

+ 链接地址: + +

+ { + resourceurlbool? +

请输入外链url

+ : + "" + } + + +

+ + + {this.props.course_is_public===true?

+ 公开: + 选中,所有用户可见,否则课堂成员可见 + +
:""} + + +

+ + +
+ 发布设置: + + + 立即发布 + + + + 延期发布 + this.onChangeTimepublish(e,index,undefined,1)} + disabledTime={disabledDateTime} + disabledDate={disabledDate} + disabled={this.state.Radiovalue===1?false:true} + /> + + + (按照设置的时间定时发布) + +
+
+ 资源描述: + {/*{course_group_publish_timestype===true?

请填写完整

:""}*/} + +
+ + {descriptiontype===true?

请输入资源描述,最大限制100个字符

:""} + {this.state.Radiovaluetype===true?

发布时间不能为空

:""} +
+ {this.props.Cancelname} + this.Saves()}>{this.props.Savesname} +
+ + + + + ) + } +} +export default sendResources; From f87becc4967af7a8a2ec427e53cc236d9e50edaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 9 Mar 2020 22:07:52 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E6=96=B9=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 298 ++++++++++++------ .../src/modules/courses/Resource/index.js | 23 +- .../courses/coursesPublic/sendResources.js | 77 +++-- 3 files changed, 274 insertions(+), 124 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 53f607b2e..37dd95298 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -1,6 +1,6 @@ -import React,{ Component } from "react"; -import { WordsBtn } from 'educoder'; -import {Tooltip,message} from 'antd'; +import React, {Component} from "react"; +import {WordsBtn} from 'educoder'; +import {Tooltip, message} from 'antd'; import {Link} from 'react-router-dom'; import {getImageUrl} from 'educoder'; import axios from 'axios' @@ -10,25 +10,40 @@ import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; -class Fileslistitem extends Component{ - constructor(props){ +class Fileslistitem extends Component { + constructor(props) { super(props); - this.state = { - - } + this.state = {} } - settingList=()=>{ - let {discussMessage}=this.props + settingList = (bools) => { + let {discussMessage} = this.props this.setState({ - discussMessageid:discussMessage.id + discussMessageid: discussMessage.id }) - this.props.Settingtypes(discussMessage.id) - } + if (bools === true) { + this.props.Settingtypes(discussMessage.id) + } else { + this.props.Settingtypess(discussMessage.id) + } - showfiles=(list)=>{ - if(this.props.checkIfLogin()===false){ + } + //外链 + showfiless = (url,id) => { + window.open(url) + let urls=`/files/${id}/update_visits.json`; + axios.post(urls,{ + }).then((result)=>{ + if(result.data.status===0){ + this.props.Updateresourcepage() + }else{ + this.props.showNotification(result.data.message); + } + }) + } + showfiles = (list) => { + if (this.props.checkIfLogin() === false) { this.props.showLoginDialog() return } @@ -43,21 +58,21 @@ class Fileslistitem extends Component{ // return // } - if(list.is_history_file===false){ + if (list.is_history_file === false) { // this.props.DownloadFileA(list.title,list.url) //window.location.href=list.url; window.open(list.url, '_blank'); - }else{ - let {discussMessage,coursesId}=this.props - let file_id=discussMessage.id - let url="/files/"+file_id+"/histories.json" - axios.get(url,{ - params:{ - course_id:coursesId + } else { + let {discussMessage, coursesId} = this.props + let file_id = discussMessage.id + let url = "/files/" + file_id + "/histories.json" + axios.get(url, { + params: { + course_id: coursesId }, - }).then((result)=>{ + }).then((result) => { - if(result.data.attachment_histories.length===0){ + if (result.data.attachment_histories.length === 0) { // if(result.data.is_pdf===true){ // this.props.ShowOnlinePdf(result.data.url) // //预览pdf @@ -66,64 +81,66 @@ class Fileslistitem extends Component{ // } // this.props.DownloadFileA(result.data.title,result.data.url) window.open(list.url, '_blank'); - }else{ + } else { this.setState({ - Showoldfiles:true, - allfiles:result.data + Showoldfiles: true, + allfiles: result.data }) } - }).catch((error)=>{ + }).catch((error) => { console.log(error) }) } } - closaoldfilesprops=()=>{ + closaoldfilesprops = () => { this.setState({ - Showoldfiles:false, + Showoldfiles: false, }) } onDelete = (id) => { this.setState({ - Modalstype:true, - Modalstopval:"是否确认删除?", - ModalCancel:this.cancelmodel, - ModalSave:()=>this.savedelete(id), + Modalstype: true, + Modalstopval: "是否确认删除?", + ModalCancel: this.cancelmodel, + ModalSave: () => this.savedelete(id), }) } - cancelmodel=()=>{ + cancelmodel = () => { this.setState({ - Modalstype:false, - Loadtype:false, - Modalstopval:"", - ModalCancel:"", - ModalSave:"", - checkBoxValues:[], + Modalstype: false, + Loadtype: false, + Modalstopval: "", + ModalCancel: "", + ModalSave: "", + checkBoxValues: [], }) } - savedelete=(id)=>{ + savedelete = (id) => { this.setState({ - Modalstype:false, + Modalstype: false, }) const cid = this.props.match.params.coursesId const url = `/files/bulk_delete.json`; - axios.delete(url, { data: { - course_id:cid, + axios.delete(url, { + data: { + course_id: cid, ids: [id], - }}) + } + }) .then((response) => { if (response.data.status == 0) { //Modalstopval:response.data.message, @@ -132,11 +149,11 @@ class Fileslistitem extends Component{ this.setState({ // Modalstype:true, // Modalstopval:"删除成功", - ModalsBottomval:"", + ModalsBottomval: "", // ModalSave:this.cancelmodel, // Loadtype:true, - checkBoxValues:[], - checkAllValue:false + checkBoxValues: [], + checkAllValue: false }) this.props.showNotification("删除成功"); @@ -147,28 +164,30 @@ class Fileslistitem extends Component{ }); } - eventStop = (event) =>{ + eventStop = (event) => { event.stopPropagation() } - render(){ + render() { - const { checkBox, - discussMessage,index + const { + checkBox, + discussMessage, index } = this.props; - return( + let bools = discussMessage.link && discussMessage.link ? false : true; + return (
{/*提示*/} - {this.state.Modalstype&&this.state.Modalstype===true?:""} + /> : ""} -
window.$(`.sourceitem${index} input`).click() }> -
this.eventStop(event)}> +
window.$(`.sourceitem${index} input`).click()}> +
this.eventStop(event)}> {checkBox} { - this.props.isAdmin ? this.showfiles(discussMessage)} - title={discussMessage.title} - className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} : "" + this.props.isAdmin ? + (bools === true ? + this.showfiles(discussMessage)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} + : + this.showfiless(discussMessage.link,discussMessage.id)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} + ) + + : "" } { - this.props.isStudent? this.showfiles(discussMessage)} - title={discussMessage.title} - className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} :"" + this.props.isStudent ? + (bools === true ? + this.showfiles(discussMessage)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} + + : + this.showfiless(discussMessage.link,discussMessage.id)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} + + ) + + + : "" } { - this.props.isNotMember===true? + this.props.isNotMember === true ? discussMessage.is_lock === true ? - {discussMessage.title} - :this.showfiles(discussMessage)} - title={discussMessage.title} - className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}:"" + {discussMessage.title} + : + (bools === true ? + + this.showfiles(discussMessage)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} : + + this.showfiless(discussMessage.link,discussMessage.id)} + title={discussMessage.title} + className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title} + + ) + + + : "" } { discussMessage.is_lock === true ? - + - :"" + : "" + } + + { + discussMessage.link && discussMessage.link ? +

外链

+ : + "" } - {discussMessage.is_publish===false?:""} - {this.props.isAdmin? - this.eventStop(event)}> + {discussMessage.is_publish === false ? : ""} + + {this.props.isAdmin ? + this.eventStop(event)}> this.settingList()}>设置 + onClick={() => this.settingList(bools)}>设置 - :""} + : ""} - {this.props.isStudent===true&&this.props.current_user.login===discussMessage.author.login? - this.eventStop(event)}> + {this.props.isStudent === true && this.props.current_user.login === discussMessage.author.login ? + this.eventStop(event)}> this.settingList()}>设置 + onClick={() => this.settingList(bools)}>设置 this.onDelete(discussMessage.id)}>删除 + onClick={() => this.onDelete(discussMessage.id)}>删除 - :""} + : ""}
- - 资源描述 :{discussMessage.description===null?"暂无描述":discussMessage.description} + 资源描述 :{discussMessage.description === null ? "暂无描述" : discussMessage.description} {/**/} {/*/!**!/*/} {/**/} @@ -365,4 +464,5 @@ class Fileslistitem extends Component{ ) } } + export default Fileslistitem; diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 250d643dc..ee6dc5750 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -597,14 +597,22 @@ class Fileslists extends Component{ this.setState({ Addanexternallink:false, }) + if(ints===1){ + this.Updateresourcepage(); + } + } } + Updateresourcepage=()=>{ + let{pagesize,tagname,searchValue,page,sort,sorttype,coursesecondcategoryid}=this.state; + this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid); + } - Cancelvisible=()=>{ + Cancelvisible=()=>{ this.setState({ Accessoryvisible:false, @@ -620,6 +628,14 @@ class Fileslists extends Component{ }) } + Settingtypess=(id)=>{ + this.setState({ + Addanexternallink:true, + Exterchainname:"资源设置", + discussMessageid:id, + }) + } + moveTos=(id)=>{ let {checkBoxValues} = this.state; @@ -863,9 +879,10 @@ class Fileslists extends Component{ {...this.state} modalname={Exterchainname} visible={Addanexternallink} + discussMessageid={discussMessageid} Cancelname={"取消"} Savesname={"确认"} - Cancel={()=>this.sendResourcessls(1,false)} + Cancel={()=>this.sendResourcessls(2,false)} categoryid={category_id} setupdate={(ints,bool)=>this.sendResourcessls(ints,bool)} has_course_groups={this.state.has_course_groups} @@ -1049,11 +1066,13 @@ class Fileslists extends Component{ {...this.props} {...this.state} discussMessage={item} + Updateresourcepage={()=>this.Updateresourcepage()} isAdmin={this.props.isAdmin()} isStudent={this.props.isStudent()} isNotMember={this.props.isNotMember()} checkBox={this.props.isAdmin()?:""} Settingtypes={(id)=>this.Settingtypes(id)} + Settingtypess={(id)=>this.Settingtypess(id)} coursesId={this.props.match.params.coursesId} updatafiledfun={()=>this.updatafiled()} index={index} diff --git a/public/react/src/modules/courses/coursesPublic/sendResources.js b/public/react/src/modules/courses/coursesPublic/sendResources.js index 2927fc1b0..6bbe308f9 100644 --- a/public/react/src/modules/courses/coursesPublic/sendResources.js +++ b/public/react/src/modules/courses/coursesPublic/sendResources.js @@ -133,7 +133,7 @@ class sendResources extends Component{ this.props.Cancel() } Saves=()=>{ - debugger + let {resourcesname,resourceurl,description,is_public,datatime,Radiovalue} =this.state; const reg = /^[\s\S]*.*[^\s][\s\S]*$/; @@ -178,30 +178,61 @@ class sendResources extends Component{ return } - let coursesId=this.props.match.params.coursesId; - let attachmentId=this.props.attachmentId; - let url="/files/upload.json"; - - - axios.post(url,{ - course_id:coursesId, - course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, - is_public:is_public, - publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, - description:description, - delay_publish:Radiovalue, - }).then((result)=>{ + if(this.props.Exterchainname==="资源设置"){ + //设置 + let coursesId=this.props.match.params.coursesId; + let attachmentId=this.props.attachmentId; + let url="/files/"+this.props.discussMessageid+".json"; + + axios.put(url,{ + name:resourcesname, + link:resourceurl, + course_id:coursesId, + course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, + is_public:is_public, + publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, + description:description, + delay_publish:Radiovalue, + }).then((result)=>{ + if(result.data.status===0){ + this.ModalCancelModalCancel(); + this.props.updataleftNavfun(); + this.props.showNotification("设置资源成功"); + this.props.setupdate(1,false) + }else{ + this.props.showNotification(result.data.message); + } + }) + }else{ + let coursesId=this.props.match.params.coursesId; + let attachmentId=this.props.attachmentId; + let url="/files/upload.json"; + + + axios.post(url,{ + name:resourcesname, + link:resourceurl, + course_id:coursesId, + course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, + is_public:is_public, + publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, + description:description, + delay_publish:Radiovalue, + }).then((result)=>{ + + + if(result.data.status===0){ + this.ModalCancelModalCancel(); + this.props.updataleftNavfun(); + this.props.showNotification("上传资源成功"); + this.props.setupdate(1,false) + }else{ + this.props.showNotification(result.data.message); + } + }) - if(result.data.status===0){ - this.ModalCancelModalCancel(); - this.props.updataleftNavfun(); - this.props.showNotification("上传资源成功"); - this.props.setupdate(this.props.attachmentId) - }else{ - this.props.showNotification(result.data.message); - } - }) + } From 68d5c72d8ec7ca5bd0220b60afbb5bec4b6254ed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 22:11:27 +0800 Subject: [PATCH 10/16] 1 --- app/controllers/users/videos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index fdd7e0c76..b317efc83 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -57,7 +57,7 @@ class Users::VideosController < Users::BaseController video = Video.find_by(id: params[:id]) return render_forbidden unless video.user_id == current_user.id || current_user.admin_or_business? return render_not_found if video.blank? - return render_error('该状态下不能删除视频') unless video.pending? + return render_error('该状态下不能删除视频') unless video.published? video.destroy! From ec1fd2519e26ffadf96578de360125aaf2a37b87 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:19:32 +0800 Subject: [PATCH 11/16] tiaoz --- app/controllers/course_videos_controller.rb | 3 ++- app/views/files/index.json.jbuilder | 2 +- app/views/weapps/attendances/_student_attendance.json.jbuilder | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/course_videos_controller.rb b/app/controllers/course_videos_controller.rb index 0d5a3e460..090c7e29a 100644 --- a/app/controllers/course_videos_controller.rb +++ b/app/controllers/course_videos_controller.rb @@ -8,7 +8,8 @@ class CourseVideosController < ApplicationController 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) + course_second_category_id = params[:category_id] || 0 + @course.course_videos.create!(title: title, link: link, is_link: 1, user_id: current_user.id, course_second_category_id: course_second_category_id) render_ok end diff --git a/app/views/files/index.json.jbuilder b/app/views/files/index.json.jbuilder index 0002cf299..3ae2ec950 100644 --- a/app/views/files/index.json.jbuilder +++ b/app/views/files/index.json.jbuilder @@ -1,4 +1,4 @@ -json.partial! "commons/success" +# json.partial! "commons/success" json.data do json.id @category_id json.name @category_name diff --git a/app/views/weapps/attendances/_student_attendance.json.jbuilder b/app/views/weapps/attendances/_student_attendance.json.jbuilder index 9461c4976..6fd5e9d70 100644 --- a/app/views/weapps/attendances/_student_attendance.json.jbuilder +++ b/app/views/weapps/attendances/_student_attendance.json.jbuilder @@ -1,4 +1,4 @@ -json.(attendance, :name, :mode) +json.(attendance, :id, :name, :mode) json.attendance_date attendance.attendance_date.strftime("%Y/%m/%d") json.start_time attendance.start_time.strftime("%H:%M") json.end_time attendance.end_time.strftime("%H:%M") From 2fb2edc140abe10c1fa8dca05bcd88f738a69088 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:21:55 +0800 Subject: [PATCH 12/16] tiaoz --- app/views/files/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/files/index.json.jbuilder b/app/views/files/index.json.jbuilder index 3ae2ec950..0002cf299 100644 --- a/app/views/files/index.json.jbuilder +++ b/app/views/files/index.json.jbuilder @@ -1,4 +1,4 @@ -# json.partial! "commons/success" +json.partial! "commons/success" json.data do json.id @category_id json.name @category_name From 9646091a82bf458e65878dab005d6f3804775002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 9 Mar 2020 22:25:53 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index ee6dc5750..e76845102 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -233,16 +233,15 @@ class Fileslists extends Component{ filesId:list.id, name:list.name, course_is_public:result.data.data.course_is_public, - isSpin:false, + page:page }) } } - }else{ - this.setState({ + } + this.setState({ isSpin:false }) - } }).catch((error)=>{ console.log(error) this.setState({ From ecab9737012adaac5fd04c89627a906b8ae992d5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:26:44 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=88=B0=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/videos/batch_publish_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 0523097a2..9ddcae146 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -41,7 +41,8 @@ class Videos::BatchPublishService < ApplicationService # 如果是课堂上传则创建课堂记录 Rails.logger.info("#####param: #{ param[:course_id]}") if param[:course_id].present? - video.course_videos.create!(course_id: param[:course_id]) + course_second_category_id = params[:category_id] || 0 + video.course_videos.create!(course_id: param[:course_id], course_second_category_id: course_second_category_id) end end end From a46ba9e7cc7a57d352c0104319547c43f0e47148 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:31:51 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=88=B0=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/videos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index b317efc83..32f81f6ed 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -85,6 +85,6 @@ class Users::VideosController < Users::BaseController end def batch_publish_params - params.permit(videos: %i[video_id title course_id]) + params.permit(videos: %i[video_id title course_id category_id]) end end \ No newline at end of file From 1c882d17e454c245521d65d8fa79897f25c91223 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:54:39 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/attendances_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 19823d42b..7da852393 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -42,6 +42,7 @@ class Weapps::AttendancesController < ApplicationController end def student_attendances + tip_exception(403) if @user_course_identity > Course::STUDENT # tip_exception("学生身份的签到列表") if @user_course_identity != Course::STUDENT member = @course.students.find_by(user_id: current_user.id) if member.present?