From a2cafe7bda8fd23ba576d6b3165aaf46d24bd558 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Wed, 25 Mar 2020 20:29:04 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix=20=E7=BB=9F=E8=AE=A1=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=92=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/school_base_statistic_service.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/admins/school_base_statistic_service.rb b/app/services/admins/school_base_statistic_service.rb index 24bf1380f..1bbc13c7c 100644 --- a/app/services/admins/school_base_statistic_service.rb +++ b/app/services/admins/school_base_statistic_service.rb @@ -5,7 +5,7 @@ class Admins::SchoolBaseStatisticService < ApplicationService sort_columns :student_count, :teacher_count, :course_count, :course_group_count, :attachment_count, :video_count, :normal_work_count, :shixun_work_count, :shixun_evaluate_count, - :student_works_num, :exercise_count, default_direction: :desc + :student_work_count, :exercise_count, default_direction: :desc def initialize(params) @params = params @@ -77,17 +77,17 @@ class Admins::SchoolBaseStatisticService < ApplicationService case sort_by_column.to_s when 'teacher_count' then schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 0') - .select("#{base_query_column}, COUNT(*) teacher_count") + .select("#{base_query_column}, COUNT(ue.id) teacher_count") when 'student_count' then schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 1') .select("#{base_query_column}, COUNT(*) student_count") when 'course_count' then - schools.joins('LEFT JOIN courses ON courses.school_id = schools.id AND courses.is_delete = false') - .select("#{base_query_column}, COUNT(*) course_count") + schools.joins('LEFT JOIN courses ON courses.school_id = schools.id AND courses.is_delete = 0') + .select("#{base_query_column}, COUNT(courses.id) course_count") when 'course_group_count' then - schools.joins("LEFT JOIN courses ON courses.school_id = schools.id AND courses.is_delete = false + schools.joins("LEFT JOIN courses ON courses.school_id = schools.id AND courses.is_delete = 0 LEFT JOIN course_groups ON course_groups.course_id = courses.id") - .select("#{base_query_column}, COUNT(*) course_group_count") + .select("#{base_query_column}, COUNT(course_groups.id) course_group_count") when 'attachment_count' then schools.joins("LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0 LEFT JOIN attachments ON attachments.container_type ='Course' AND attachments.container_id = cs.id") @@ -106,14 +106,14 @@ class Admins::SchoolBaseStatisticService < ApplicationService .select("#{base_query_column}, COUNT(*) shixun_work_count") when 'student_work_count' then schools.joins("LEFT JOIN school_reports ON school_reports.school_id = schools.id") - .select("#{base_query_column}, COUNT(*) student_work_count") + .select("#{base_query_column}, SUM(student_work_count) AS student_work_count") when 'shixun_evaluate_count' then schools.joins('LEFT JOIN school_reports ON school_reports.school_id = schools.id') - .select("#{base_query_column}, COUNT(*) shixun_evaluate_count") + .select("#{base_query_column}, SUM(shixun_evaluate_count) AS shixun_evaluate_count") when 'exercise_count' then schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0 LEFT JOIN exercises ON exercises.course_id = cs.id') - .select("#{base_query_column}, COUNT(*) exercise_count") + .select("#{base_query_column}, COUNT(exercises.id) exercise_count") end end From 4c9d349bbeda7b620a0b55626e07a79c0d1a8976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 25 Mar 2020 20:45:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/busyWork/PublishRightnow.js | 3 ++- .../coursesPublic/OneSelfOrderModal.js | 20 ++++++------------- .../poll/pollPublicBtn/ImmediatelyPublish.js | 15 ++++++++------ .../shixunHomework/ShixunStudentWork.js | 8 +++++--- .../shixunHomework/Trainingjobsetting.js | 8 +++++--- .../shixunHomework/Workquestionandanswer.js | 8 +++++--- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/PublishRightnow.js b/public/react/src/modules/courses/busyWork/PublishRightnow.js index 54e87a4c5..7afdfac5e 100644 --- a/public/react/src/modules/courses/busyWork/PublishRightnow.js +++ b/public/react/src/modules/courses/busyWork/PublishRightnow.js @@ -190,12 +190,13 @@ class PublishRightnow extends Component{ this.setState({ visible : false }) return; } - this.showDialog(response.data.course_groups) + this.setState({ course_groups: response.data.course_groups, starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, starttimeslate_time:response.data.late_time===undefined||response.data.late_time===null||response.data.late_time===""?undefined:response.data.late_time, }) + this.showDialog(response.data.course_groups) }) .catch(function (error) { console.log(error); diff --git a/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js b/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js index 9c57cc88c..8cdeb3a36 100644 --- a/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js +++ b/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js @@ -58,11 +58,7 @@ class OneSelfOrderModal extends Component{ // }else{ // item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm"); // } - if(this.props.starttimesend){ - item.end_time = moment(moment(handleDateString(this.props.starttimesend))).format("YYYY-MM-DD HH:mm"); - }else{ - item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); - } + item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); newarr.push(item) } else { newarr.push(item) @@ -78,7 +74,7 @@ class OneSelfOrderModal extends Component{ if(this.props.starttimes===undefined||this.props.starttimes===""||this.props.starttimes===null){ if(this.props.starttimesend===undefined){ this.setState({ - endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) }else{ this.setState({ @@ -89,7 +85,7 @@ class OneSelfOrderModal extends Component{ }else{ if(this.props.starttimesend===undefined){ this.setState({ - endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) }else{ this.setState({ @@ -108,11 +104,7 @@ class OneSelfOrderModal extends Component{ course_groups.map((item,key)=>{ if(item.end_time===null){ // item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); - if(this.props.starttimesend){ - item.end_time = moment(moment(handleDateString(this.props.starttimesend))).format("YYYY-MM-DD HH:mm"); - }else{ - item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); - } + item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"); newarr.push(item) }else{ newarr.push(item) @@ -131,7 +123,7 @@ class OneSelfOrderModal extends Component{ if(this.props.starttimes===undefined||this.props.starttimes===""||this.props.starttimes===null){ if(this.props.starttimesend===undefined){ this.setState({ - endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) }else{ this.setState({ @@ -142,7 +134,7 @@ class OneSelfOrderModal extends Component{ }else{ if(this.props.starttimesend===undefined){ this.setState({ - endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm") + endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm") }) }else{ this.setState({ diff --git a/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js b/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js index 933ca1996..bbc617026 100644 --- a/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js +++ b/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js @@ -57,11 +57,12 @@ class Immediatelypublish extends Component{ if(this.props.Exercisetype==="exercise"){ let url=`/exercises/${this.props.match.params.Id}/publish_groups.json`; axios.get(url).then((response) => { - if(response.status===200){ + if (response.data) { + let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; + this.setState({ modalname:"立即发布", modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, - OneSelftype:true, Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", // Botvalleft:"暂不发布", Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, @@ -73,8 +74,9 @@ class Immediatelypublish extends Component{ Cancel:this.homeworkhide, Saves:this.homeworkstartend, course_groups:response.data.course_groups, - starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, + starttimesend:starttimesend, immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true, + OneSelftype:true, }) } @@ -84,12 +86,12 @@ class Immediatelypublish extends Component{ }else{ let url=`/polls/${this.props.match.params.pollId}/publish_groups.json`; axios.get(url).then((response) => { - if(response){ + if (response.data) { + let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; this.setState({ modalname:"立即发布", modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, - OneSelftype:true, Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", // Botvalleft:"暂不发布", Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, @@ -101,8 +103,9 @@ class Immediatelypublish extends Component{ Cancel:this.homeworkhide, Saves:this.homeworkstartend, course_groups:response.data.course_groups, - starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, + starttimesend:starttimesend, immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true, + OneSelftype:true, }) } }).catch((error) => { diff --git a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js index 7bb53750a..c5792bc29 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js @@ -383,14 +383,15 @@ class ShixunStudentWork extends Component { axios.get(url).then((response) => { - if(response.status===200){ + if (response.data) { const dataformat = 'YYYY-MM-DD HH:mm'; let starttime= this.props.getNowFormatDates(1); let endtime=this.props.getNowFormatDates(2); + let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; + this.setState({ modalname:"立即发布", modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, - OneSelftype:true, Topval:"学生将立即收到作业", // Botvalleft:"暂不发布", Botval:`本操作只对"未发布"的作业有效`, @@ -402,8 +403,9 @@ class ShixunStudentWork extends Component { Saves:this.homeworkstartend, course_groups:response.data.course_groups, starttimes:starttime, - starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, + starttimesend:starttimesend, typs:"start", + OneSelftype:true, }) } }).catch((error) => { diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 64a956d28..26abca297 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -1813,20 +1813,21 @@ class Trainingjobsetting extends Component { axios.get(url).then((response) => { - if (response.status === 200) { + if (response.data) { const dataformat = 'YYYY-MM-DD HH:mm'; let starttime = this.props.getNowFormatDates(1); let endtime = this.props.getNowFormatDates(2); + let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; + this.setState({ modalname: "立即发布", modaltype: response.data.course_groups === null || response.data.course_groups.length === 0 ? 2 : 1, - OneSelftype: true, Topval: "学生将立即收到作业", // Botvalleft:"暂不发布", Botval: `本操作只对"未发布"的作业有效`, starttime: "发布时间:" + moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), starttimes: starttime, - starttimesend: response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time, + starttimesend:starttimesend, typs: "start", endtime: "截止时间:" + endtime, Cancelname: "暂不发布", @@ -1836,6 +1837,7 @@ class Trainingjobsetting extends Component { course_groups:response.data.course_groups, immediatelyopen:true, modallate_time:response.data.late_time, + OneSelftype: true, }) } }).catch((error) => { diff --git a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js index 06fe12965..b3ab36973 100644 --- a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js +++ b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js @@ -159,14 +159,15 @@ class Workquestionandanswer extends Component { axios.get(url).then((response) => { - if (response.status === 200) { + if (response.data) { const dataformat = 'YYYY-MM-DD HH:mm'; let starttime = this.props.getNowFormatDates(1); let endtime = this.props.getNowFormatDates(2); + let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; + this.setState({ modalname: "立即发布", modaltype: response.data.course_groups === null || response.data.course_groups.length === 0 ? 2 : 1, - OneSelftype: true, Topval: "学生将立即收到作业", // Botvalleft:"暂不发布", Botval: `本操作只对"未发布"的作业有效`, @@ -178,8 +179,9 @@ class Workquestionandanswer extends Component { Saves: this.homeworkstartend, course_groups: response.data.course_groups, starttimes: starttime, - starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time, + starttimesend:starttimesend, typs: "start", + OneSelftype: true, }) } }).catch((error) => { From f21af5046e86cbecab37350f1c9d43675ae1e7a4 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Fri, 14 Feb 2020 20:21:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8D=87=E7=BA=A7=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/upgrade_notices/index.js | 82 +++++++++++++++++++ .../admins/upgrade_notices_controller.rb | 54 ++++++++++++ app/models/upgrade_notice.rb | 2 + app/views/admins/shared/_sidebar.html.erb | 3 +- .../admins/upgrade_notices/destroy.js.erb | 2 + app/views/admins/upgrade_notices/edit.js.erb | 14 ++++ .../admins/upgrade_notices/index.html.erb | 15 ++++ app/views/admins/upgrade_notices/index.js.erb | 1 + .../_create_upgrade_notice_modal.html.erb | 26 ++++++ .../_edit_upgrade_notice_modal.html.erb | 25 ++++++ .../upgrade_notices/shared/_list.html.erb | 49 +++++++++++ config/initializers/time_format.rb | 28 +++++++ config/routes.rb | 4 +- .../20200214070108_create_upgrade_notices.rb | 12 +++ 14 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/admins/upgrade_notices/index.js create mode 100644 app/controllers/admins/upgrade_notices_controller.rb create mode 100644 app/models/upgrade_notice.rb create mode 100644 app/views/admins/upgrade_notices/destroy.js.erb create mode 100644 app/views/admins/upgrade_notices/edit.js.erb create mode 100644 app/views/admins/upgrade_notices/index.html.erb create mode 100644 app/views/admins/upgrade_notices/index.js.erb create mode 100644 app/views/admins/upgrade_notices/shared/_create_upgrade_notice_modal.html.erb create mode 100644 app/views/admins/upgrade_notices/shared/_edit_upgrade_notice_modal.html.erb create mode 100644 app/views/admins/upgrade_notices/shared/_list.html.erb create mode 100644 config/initializers/time_format.rb create mode 100644 db/migrate/20200214070108_create_upgrade_notices.rb diff --git a/app/assets/javascripts/admins/upgrade_notices/index.js b/app/assets/javascripts/admins/upgrade_notices/index.js new file mode 100644 index 000000000..5ad9c7ce1 --- /dev/null +++ b/app/assets/javascripts/admins/upgrade_notices/index.js @@ -0,0 +1,82 @@ +$(document).on('turbolinks:load', function() { + if ($('body.admins-upgrade-notices-index-page').length > 0) { + window.upgradeNoticeForm = function(clazz) { + var $modal = $('.modal.admin-' + clazz + '-upgrade-notice-modal'); + var $form = $modal.find('form.admin-' + clazz + '-upgrade-notice-form'); + + $form.validate({ + errorElement: 'span', + errorClass: 'danger text-danger', + rules: { + 'upgrade_notice[title]': { + required: true + }, + 'upgrade_notice[content]': { + required: true + }, + 'upgrade_notice[start_at]': { + required: true + }, + 'upgrade_notice[end_at]': { + required: true + } + } + }); + + $modal.on('click', '.submit-btn', function() { + $form.find('.error').html(''); + console.log('url', $form.data('url'), $form) + + if ($form.valid()) { + var url = $form.attr('action'); + var newDate = new Date(); + var begin_time = Date.parse($('.' + clazz +'_start_at').val()); + var end_time = Date.parse($('.' + clazz +'_end_at').val()); + if (begin_time < newDate) { + $('.' + clazz +'_end_at').addClass('danger text-danger'); + $form.find('.error').html('开始时间应大于当前时间'); + return false + } else if (end_time < newDate) { + $form.find('.error').html('结束时间应大于当前时间'); + $('.' + clazz +'_end_at').addClass('danger text-danger'); + return false + } else if (end_time < begin_time) { + $form.find('.error').html('结束时间应大于开始时间'); + $('.' + clazz +'_end_at').addClass('danger text-danger'); + return false + } + + $.ajax({ + method: clazz == 'create' ? 'POST' : 'PUT', + dataType: 'json', + url: url, + data: $form.serialize(), + success: function() { + $.notify({ message: '创建成功' }); + $modal.modal('hide'); + + setTimeout(function() { + window.location.reload(); + }, 500); + }, + error: function(res) { + var data = res.responseJSON; + $form.find('.error').html(data.message); + } + }); + } + }); + } + + var timeOptions = { + autoclose: 1, + language: 'zh-CN', + format: 'yyyy-mm-dd hh:ii', + minuteStep: 10 + }; + + $(".create_start_at").datetimepicker(timeOptions) + $(".create_end_at").datetimepicker(timeOptions) + upgradeNoticeForm("create"); + } +}); \ No newline at end of file diff --git a/app/controllers/admins/upgrade_notices_controller.rb b/app/controllers/admins/upgrade_notices_controller.rb new file mode 100644 index 000000000..053a72106 --- /dev/null +++ b/app/controllers/admins/upgrade_notices_controller.rb @@ -0,0 +1,54 @@ +class Admins::UpgradeNoticesController < Admins::BaseController + + def index + params[:sort_by] ||= 'created_at' + params[:sort_direction] ||= 'desc' + + @upgrade_notice = UpgradeNotice.new( + content: '为了给大家提供更优质的体验,平台将于2018年5月22日00:00开始对系统进行升级。升级期间实训和基于项目的分组作业将暂停服务。 + 系统拟于2018年5月22日10:00恢复服务。请大家知悉,并提前做好教学安排。 + 带来不便,敬请谅解。', + title: 'educoder系统升级暂停服务通知') + + @upgrade_notices = UpgradeNotice.order("created_at #{params[:sort_direction]}") + @upgrade_notices = paginate @upgrade_notices + end + + def create + upgrade_notice = UpgradeNotice.new(upgrade_notice_params) + if upgrade_notice.save + render_ok + else + render_error upgrade_notice.error.full_messages.join(",") + end + end + + def destroy + check_upgrade_notice + @upgrade_notice.destroy + end + + def edit + check_upgrade_notice + end + + def update + check_upgrade_notice + if @upgrade_notice.update(upgrade_notice_params) + render_ok + else + render_error @upgrade_notice.error.full_messages.join(",") + end + end + + + private + + def upgrade_notice_params + params.require(:upgrade_notice).permit(:title, :content, :start_at, :end_at) + end + + def check_upgrade_notice + @upgrade_notice = UpgradeNotice.find(params[:id]) + end +end diff --git a/app/models/upgrade_notice.rb b/app/models/upgrade_notice.rb new file mode 100644 index 000000000..b975c0864 --- /dev/null +++ b/app/models/upgrade_notice.rb @@ -0,0 +1,2 @@ +class UpgradeNotice < ApplicationRecord +end diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index d77e4ed4e..6c8a3938a 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -86,7 +86,8 @@
  • <%= sidebar_item_group('#comments-submenu', '消息', icon: 'comments') do %>
  • <%= sidebar_item(admins_shixun_feedback_messages_path, '实训反馈', icon: 'comment', controller: 'admins-shixun_feedback_messages') %>
  • - <% end %> +
  • <%= sidebar_item(admins_upgrade_notices_path, '系统升级提醒', icon: 'envelope-open', controller: 'admins-upgrade_notices') %>
  • + <% end %>
  • diff --git a/app/views/admins/upgrade_notices/destroy.js.erb b/app/views/admins/upgrade_notices/destroy.js.erb new file mode 100644 index 000000000..4fc764c72 --- /dev/null +++ b/app/views/admins/upgrade_notices/destroy.js.erb @@ -0,0 +1,2 @@ +$.notify({ message: '删除成功' }); +$(".upgrade-notice-item-<%= @upgrade_notice.id %>").remove(); \ No newline at end of file diff --git a/app/views/admins/upgrade_notices/edit.js.erb b/app/views/admins/upgrade_notices/edit.js.erb new file mode 100644 index 000000000..fe92e77fa --- /dev/null +++ b/app/views/admins/upgrade_notices/edit.js.erb @@ -0,0 +1,14 @@ +$('.admin-modal-container').html("<%= j( render partial: 'admins/upgrade_notices/shared/edit_upgrade_notice_modal', locals: { upgrade_notice: @upgrade_notice } ) %>"); +$('.modal.admin-edit-upgrade-notice-modal').modal('show'); + +var timeOptions = { + autoclose: 1, + language: 'zh-CN', + format: 'yyyy-mm-dd hh:ii', + minuteStep: 10 +}; + +$(".edit_start_at").datetimepicker(timeOptions) +$(".edit_end_at").datetimepicker(timeOptions) + +upgradeNoticeForm("edit"); \ No newline at end of file diff --git a/app/views/admins/upgrade_notices/index.html.erb b/app/views/admins/upgrade_notices/index.html.erb new file mode 100644 index 000000000..55c30d981 --- /dev/null +++ b/app/views/admins/upgrade_notices/index.html.erb @@ -0,0 +1,15 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('系统升级提醒', admins_upgrade_notices_path) %> +<% end %> + +
    +
    + <%= javascript_void_link '新增', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-upgrade-notice-modal' } %> +
    +
    + +
    + <%= render(partial: 'admins/upgrade_notices/shared/list') %> +
    + +<%= render partial: 'admins/upgrade_notices/shared/create_upgrade_notice_modal', locals: {upgrade_notice: @upgrade_notice} %> diff --git a/app/views/admins/upgrade_notices/index.js.erb b/app/views/admins/upgrade_notices/index.js.erb new file mode 100644 index 000000000..00da94961 --- /dev/null +++ b/app/views/admins/upgrade_notices/index.js.erb @@ -0,0 +1 @@ +$(".admin-upgrade-notices-list-container").html("<%= j render partial: "admins/upgrade_notices/shared/list",locals: {upgrade_notices: @upgrade_notices} %>") \ No newline at end of file diff --git a/app/views/admins/upgrade_notices/shared/_create_upgrade_notice_modal.html.erb b/app/views/admins/upgrade_notices/shared/_create_upgrade_notice_modal.html.erb new file mode 100644 index 000000000..332acbd2e --- /dev/null +++ b/app/views/admins/upgrade_notices/shared/_create_upgrade_notice_modal.html.erb @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/views/admins/upgrade_notices/shared/_edit_upgrade_notice_modal.html.erb b/app/views/admins/upgrade_notices/shared/_edit_upgrade_notice_modal.html.erb new file mode 100644 index 000000000..f8d8e3aee --- /dev/null +++ b/app/views/admins/upgrade_notices/shared/_edit_upgrade_notice_modal.html.erb @@ -0,0 +1,25 @@ + diff --git a/app/views/admins/upgrade_notices/shared/_list.html.erb b/app/views/admins/upgrade_notices/shared/_list.html.erb new file mode 100644 index 000000000..79a872432 --- /dev/null +++ b/app/views/admins/upgrade_notices/shared/_list.html.erb @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + <% if @upgrade_notices.present? %> + <% @upgrade_notices.each_with_index do |notice, index| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题详情开始时间结束时间<%= sort_tag('创建时间', name: 'created_at', path: admins_upgrade_notices_path) %>更新时间操作
    <%= index + 1 %> + <%= notice.title %> + + <%= notice.content %> + + <%= notice.start_at.to_s %> + + <%= notice.end_at.to_s %> + + <%= notice.created_at.to_s %> + + <%= notice.updated_at.to_s %> + + <%= link_to '编辑', edit_admins_upgrade_notice_path(notice), remote: true, class: 'edit-action' %> + <%= delete_link '删除', admins_upgrade_notice_path(notice, element: ".upgrade-notice-item-#{notice.id}"), class: 'delete-upgrade-notice-action' %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: @upgrade_notices } %> \ No newline at end of file diff --git a/config/initializers/time_format.rb b/config/initializers/time_format.rb new file mode 100644 index 000000000..98a4c48bc --- /dev/null +++ b/config/initializers/time_format.rb @@ -0,0 +1,28 @@ +Time::DATE_FORMATS[:db2] = '%Y-%m-%d %H:%M:%S' + +Time::DATE_FORMATS[:default] = ->(time){ + Time.zone = 'Beijing' + t = Time.zone.at time + t.strftime '%Y-%m-%d %H:%M:%S' +} + +Time::DATE_FORMATS[:sh] = ->(time){ + t = Time.zone.at time + t.strftime '%y-%m-%d %H:%M:%S' +} + +Time::DATE_FORMATS[:date] = ->(time){ + t = Time.zone.at time + t.strftime '%Y-%m-%d' +} + +Time::DATE_FORMATS[:h] = ->(time){ + t = Time.zone.at time + t.strftime '%H:%M' +} + +Time::DATE_FORMATS[:datetime] = '%Y-%m-%d %H:%M' + +Date::DATE_FORMATS[:date] = ->(date){ + date.strftime '%Y-%m-%d' +} diff --git a/config/routes.rb b/config/routes.rb index 9a471fb7f..2f0fc57c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,7 @@ Rails.application.routes.draw do get 'auth/cas/callback', to: 'oauth/cas#create' get 'ecloud/ecloud_login', to: 'ecloud#ecloud_login_callback' - + resources :edu_settings @@ -31,6 +31,7 @@ Rails.application.routes.draw do resources :watch_video_histories, only: [:create] + resources :jupyters do collection do get :save_with_tpi @@ -1136,6 +1137,7 @@ Rails.application.routes.draw do namespace :admins do get '/', to: 'dashboards#index' + resources :upgrade_notices resources :major_informations, only: [:index] resources :ec_templates, only: [:index, :destroy] do collection do diff --git a/db/migrate/20200214070108_create_upgrade_notices.rb b/db/migrate/20200214070108_create_upgrade_notices.rb new file mode 100644 index 000000000..d887bf4da --- /dev/null +++ b/db/migrate/20200214070108_create_upgrade_notices.rb @@ -0,0 +1,12 @@ +class CreateUpgradeNotices < ActiveRecord::Migration[5.2] + def change + create_table :upgrade_notices do |t| + t.string :title + t.text :content + t.datetime :start_at + t.datetime :end_at + + t.timestamps + end + end +end From d50ce2c97d947ac461505a7b314b96cf4289ca21 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 25 Mar 2020 21:35:39 +0800 Subject: [PATCH 4/5] =?UTF-8?q?url=E5=AE=89=E5=85=A8=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 ++-- app/views/users/videos/_video.json.jbuilder | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1039a648a..6d5688078 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,9 +28,9 @@ module ApplicationHelper end # MD5加密 - def base64_encode(content) + def url_base64_encode(content) return nil if content.blank? - Base64.encode64(content) + Base64.urlsafe_encode64(content) end def graduation_navigation graduation diff --git a/app/views/users/videos/_video.json.jbuilder b/app/views/users/videos/_video.json.jbuilder index ac030ce12..707c0a5cf 100644 --- a/app/views/users/videos/_video.json.jbuilder +++ b/app/views/users/videos/_video.json.jbuilder @@ -1,6 +1,6 @@ json.extract! video, :id, :title, :cover_url, :file_url, :play_url, :vv, :user_id, :transcoded -json.play_url base64_encode(video.play_url) -json.file_url base64_encode(video.file_url) +json.play_url url_base64_encode(video.play_url) +json.file_url url_base64_encode(video.file_url) json.play_duration video.video_play_duration json.published_at video.display_published_at json.created_at video.display_created_at From 762cd64b7f9057300fb0f51131fc97a62f656795 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 25 Mar 2020 21:39:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=92=8C=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=9A=84=E7=AB=8B=E5=8D=B3=E5=8F=91=E5=B8=83=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercises/publish_groups.json.jbuilder | 2 +- app/views/polls/publish_groups.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/exercises/publish_groups.json.jbuilder b/app/views/exercises/publish_groups.json.jbuilder index 72cefdd1a..68cf95d2f 100644 --- a/app/views/exercises/publish_groups.json.jbuilder +++ b/app/views/exercises/publish_groups.json.jbuilder @@ -1,6 +1,6 @@ json.course_groups @course_groups do |group| json.id group.id json.name group.name - json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time + json.end_time @exercise.unified_setting ? @exercise.end_time : @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time end json.end_time @exercise.end_time \ No newline at end of file diff --git a/app/views/polls/publish_groups.json.jbuilder b/app/views/polls/publish_groups.json.jbuilder index f63a2ea90..8cf49e959 100644 --- a/app/views/polls/publish_groups.json.jbuilder +++ b/app/views/polls/publish_groups.json.jbuilder @@ -1,6 +1,6 @@ json.course_groups @course_groups do |group| json.id group.id json.name group.name - json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time + json.end_time @poll.unified_setting ? @poll.end_time : @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time end json.end_time @poll.end_time \ No newline at end of file