Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
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
|
@ -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…
Reference in new issue