Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
jingquan huang 5 years ago
commit daff54613d

@ -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

@ -710,10 +710,10 @@ class GamesController < ApplicationController
resubmit_identifier = @game.resubmit_identifier resubmit_identifier = @game.resubmit_identifier
# 如果没有超时并且正在评测中 # 如果没有超时并且正在评测中
# 判断评测中的状态有两种1、如果之前没有通关的只需判断status为1即可如果通过关则判断game的resubmit_identifier是否更新 # 判断评测中的状态有两种1、如果之前没有通关的只需判断status为1即可如果通过关则判断game的resubmit_identifier是否更新
uid_logger("################game_status: #{@game.status}") # uid_logger("################game_status: #{@game.status}")
uid_logger("################params[:resubmit]: #{params[:resubmit]}") # uid_logger("################params[:resubmit]: #{params[:resubmit]}")
uid_logger("################resubmit_identifier: #{resubmit_identifier}") # uid_logger("################resubmit_identifier: #{resubmit_identifier}")
uid_logger("################time_out: #{params[:time_out]}") # uid_logger("################time_out: #{params[:time_out]}")
if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? && if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? &&
(params[:resubmit] != resubmit_identifier))) (params[:resubmit] != resubmit_identifier)))
# 代码评测的信息 # 代码评测的信息

@ -1,4 +1,4 @@
class Users::AccountsController < Users::BaseController class Users::AccountsController < Users::BaseAccountController
before_action :private_user_resources! before_action :private_user_resources!
def show def show

@ -4,4 +4,12 @@ class Users::BaseAccountController < Users::BaseController
def observed_user def observed_user
@_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id])) @_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id]))
end end
private
def require_login
return if User.current.logged?
tip_exception(401, "..")
end
end end

@ -148,7 +148,7 @@ class CourseMember < ApplicationRecord
if teacher_groups.count > 0 if teacher_groups.count > 0
member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id).compact 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 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})") course_members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})")
else else

@ -26,6 +26,9 @@ if @task.published? || @user_course_identity < Course::STUDENT
# 是否具有分组 # 是否具有分组
json.have_grouping @task.have_grouping? json.have_grouping @task.have_grouping?
# 是否关联项目
json.have_project @task.have_grouping? && @task.base_on_project
if @user_course_identity == Course::STUDENT if @user_course_identity == Course::STUDENT
json.commit_count grduationwork_count @task, 1 json.commit_count grduationwork_count @task, 1
json.uncommit_count grduationwork_count @task, 0 json.uncommit_count grduationwork_count @task, 0

@ -1,7 +1,8 @@
Rails.application.routes.draw do Rails.application.routes.draw do
require 'sidekiq/web' require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq' require 'admin_constraint'
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new
resources :edu_settings resources :edu_settings
scope '/api' do scope '/api' do

@ -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
Loading…
Cancel
Save