From 14aadb37b5a75e620d64760fc1640e312f55f6fd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 11 Jul 2019 16:22:10 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/graduation_tasks/tasks_list.json.jbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index ac5aa050e..8ee2f78af 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -26,6 +26,9 @@ if @task.published? || @user_course_identity < Course::STUDENT # 是否具有分组 json.have_grouping @task.have_grouping? + # 是否关联项目 + json.have_project @task.have_grouping? && @task.base_on_project + if @user_course_identity == Course::STUDENT json.commit_count grduationwork_count @task, 1 json.uncommit_count grduationwork_count @task, 0 From aa4dbf0f06ce1904adf0d9f25c35f3b4feddfa34 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 11 Jul 2019 16:31:18 +0800 Subject: [PATCH 2/7] account manange not check profile complete --- app/controllers/users/base_account_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/users/base_account_controller.rb b/app/controllers/users/base_account_controller.rb index b693eaab5..29de52b26 100644 --- a/app/controllers/users/base_account_controller.rb +++ b/app/controllers/users/base_account_controller.rb @@ -4,4 +4,12 @@ class Users::BaseAccountController < Users::BaseController def observed_user @_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id])) end + + private + + def require_login + return if User.current.logged? + + tip_exception(401, "..") + end end From a50cbc9e0bd4274208dbb0674c437ef913ef404d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 11 Jul 2019 16:35:34 +0800 Subject: [PATCH 3/7] fix --- app/controllers/users/accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/accounts_controller.rb b/app/controllers/users/accounts_controller.rb index e88ff4564..dff5115e1 100644 --- a/app/controllers/users/accounts_controller.rb +++ b/app/controllers/users/accounts_controller.rb @@ -1,4 +1,4 @@ -class Users::AccountsController < Users::BaseController +class Users::AccountsController < Users::BaseAccountController before_action :private_user_resources! def show From 2f5f0cef16da9201934e34513dd9fd51310ea7ab Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 16:36:10 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 6ffc7f0ce..929af8f47 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -710,10 +710,10 @@ class GamesController < ApplicationController resubmit_identifier = @game.resubmit_identifier # 如果没有超时并且正在评测中 # 判断评测中的状态有两种:1、如果之前没有通关的,只需判断status为1即可;如果通过关,则判断game的resubmit_identifier是否更新 - uid_logger("################game_status: #{@game.status}") - uid_logger("################params[:resubmit]: #{params[:resubmit]}") - uid_logger("################resubmit_identifier: #{resubmit_identifier}") - uid_logger("################time_out: #{params[:time_out]}") + # uid_logger("################game_status: #{@game.status}") + # uid_logger("################params[:resubmit]: #{params[:resubmit]}") + # uid_logger("################resubmit_identifier: #{resubmit_identifier}") + # uid_logger("################time_out: #{params[:time_out]}") if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier))) # 代码评测的信息 From e929ec427ed780a8ba7ea32839c45dd75b6e22f8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 01:03:44 +0800 Subject: [PATCH 5/7] =?UTF-8?q?job=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_member.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course_member.rb b/app/models/course_member.rb index 52c13dbbf..65849e5de 100644 --- a/app/models/course_member.rb +++ b/app/models/course_member.rb @@ -148,7 +148,7 @@ class CourseMember < ApplicationRecord if teacher_groups.count > 0 member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id).compact - none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1 + none_group_teachers = teacher_groups.pluck(:course_member_id).compact.size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1 teachers = course.teachers.where("course_members.id not in (#{none_group_teachers}) or course_members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})") else From 2c143af77446adc8c24f28640db3776979f34afb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 13 Jul 2019 10:30:22 +0800 Subject: [PATCH 6/7] =?UTF-8?q?sidekiq=E7=9B=91=E6=8E=A7=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/constraint/admin_constraint.rb | 7 +++++++ config/routes.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/constraint/admin_constraint.rb diff --git a/app/constraint/admin_constraint.rb b/app/constraint/admin_constraint.rb new file mode 100644 index 000000000..3ddf9a11e --- /dev/null +++ b/app/constraint/admin_constraint.rb @@ -0,0 +1,7 @@ +class AdminConstraint + def matches?(request) + return false unless request.session[:user_id] + user = User.find request.session[:user_id] + user && user.admin? + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7e34363d1..d9e10e4cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,8 @@ Rails.application.routes.draw do require 'sidekiq/web' - mount Sidekiq::Web => '/sidekiq' + require 'admin_constraint' + mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new resources :edu_settings scope '/api' do From 9028cc193e49f647c1b22a9e9361933b5c62aabd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Jul 2019 11:07:01 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=89=80=E6=9C=89Markdown=E5=9B=BE=E7=89=87=E7=9A=84=E7=9A=84u?= =?UTF-8?q?rl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...modify_md_attachment_url_for_md_cotents.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb diff --git a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb new file mode 100644 index 000000000..188e017a5 --- /dev/null +++ b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb @@ -0,0 +1,30 @@ +class ModifyMdAttachmentUrlForMdCotents < ActiveRecord::Migration[5.2] + def change + # 更新MarkDown图片的URL + homework_commons = HomeworkCommon.all + homework_commons.find_each do |hc| + hc.update_column(:description, hc.description.gsub("![](/attachments/download", "![](/api/attachments")) if hc.description.present? + end + + challenges = Challenge.all.unscoped + challenges.find_each do |c| + c.update_column(:task_pass, c.task_pass.gsub("![](/attachments/download", "![](/api/attachments")) if c.task_pass.present? + end + + challenge_answers = ChallengeAnswer.all.unscoped + challenge_answers.find_each do |ca| + ca.update_column(:contents, ca.contents.gsub("![](/attachments/download", "![](/api/attachments")) if ca.contents.present? + end + + shixun_infos = ShixunInfo.all + shixun_infos.find_each do |si| + si.update_column(:propaedeutics, si.propaedeutics.gsub("![](/attachments/download", "![](/api/attachments")) if si.propaedeutics.present? + si.update_column(:description, si.description.gsub("![](/attachments/download", "![](/api/attachments")) if si.description.present? + end + + subjects = Subject.all + subjects.find_each do |s| + s.update_column(:description, s.description.gsub("![](/attachments/download", "![](/api/attachments")) if s.description.present? + end + end +end