Merge branch 'develop' into educoder

dev_haigong
daiao 6 years ago
commit 8019bc3e0b

@ -465,7 +465,7 @@ class ChallengesController < ApplicationController
render_404
return
else
if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun))
if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun)) || @shixun.status == -1
render_403
return
end

@ -158,7 +158,7 @@ class ManagementsController < ApplicationController
@sub_type = 8
@g = Gitlab.client
if params[:search]
myshixun_id = Game.where(:identifier => params[:search]).pluck(:myshixun_id)
myshixun_id = Game.where("identifier = #{params[:search]} or id = #{params[:search]}").pluck(:myshixun_id)
@myshixuns = Myshixun.where(:id => myshixun_id).includes(:shixun)
else
@myshixuns = Myshixun.where("0=0").includes(:shixun)

@ -1115,8 +1115,8 @@ class ShixunsController < ApplicationController
g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present?
apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun")
apply_record.delete_all if apply_record
HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决
@shixun.destroy
#HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决
@shixun.update_attribute(:status, -1)
respond_to do |format|
if params[:come_from] == "admin"
format.html{ redirect_to shixuns_managements_path }
@ -1215,7 +1215,7 @@ class ShixunsController < ApplicationController
# Find shixun of id params[:id]
def find_shixun
@shixun = Shixun.find_by_identifier(params[:id])
render_404 if @shixun.nil?
render_404 if @shixun.nil? || @shixun.status == -1
rescue ActiveRecord::RecordNotFound
render_404
end
@ -1362,4 +1362,8 @@ class ShixunsController < ApplicationController
def validation_email
render_403 if User.current.mail.blank?
end
def validate_shixun
end
end

@ -73,7 +73,7 @@ class Shixun < ActiveRecord::Base
end
def fork_identifier
self.fork_from.nil? ? "--" : Shixun.find(self.fork_from).try(:identifier)
self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier)
end
def get_fork

@ -0,0 +1,11 @@
class ModifyForkFromForShixuns < ActiveRecord::Migration
def up
shixuns = Shixun.where(:fork_from => 1933)
shixuns.each do |shixun|
shixun.update_attribute(:fork_from, nil)
end
end
def down
end
end
Loading…
Cancel
Save