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

chromesetting
cxt 5 years ago
commit 5b5d1f0acb

@ -1,9 +1,9 @@
class HackUserLastestCodesController < ApplicationController
before_action :require_login, except: [:listen_result]
before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code,
before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, :add_notes,
:listen_result, :result, :submit_records, :restore_initial_code]
before_action :update_user_hack_status, only: [:code_debug, :code_submit]
#before_action :require_auth_identity, only: [:restore_initial_code, :sync_code]
before_action :require_auth_identity, only: [:add_notes]
before_action :require_manager_identity, only: [:show, :update_code, :restore_initial_code, :sync_code]
def show
@ -67,7 +67,6 @@ class HackUserLastestCodesController < ApplicationController
end
# 提交记录详情
def record_detail
@hack_user = HackUserCode.find params[:id]
@ -109,6 +108,11 @@ class HackUserLastestCodesController < ApplicationController
end
def add_notes
@my_hack.update_attribute(:notes, params[:notes])
render_ok
end
private
def find_my_hack
@my_hack = HackUserLastestCode.find_by(identifier: params[:identifier])

@ -1,6 +1,6 @@
class HackSet < ApplicationRecord
#validates :input, presence: { message: "测试集输入不能为空" }
#validates :output, presence: { message: "测试集输出不能为空" }
validates :input, presence: { message: "测试集输入不能为空" }
validates :output, presence: { message: "测试集输出不能为空" }
validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同"
# 编程题测试集
belongs_to :hack

@ -12,4 +12,6 @@ class HackUserLastestCode < ApplicationRecord
scope :mine_hack, ->(author_id){ where(user_id: author_id) }
scope :passed, -> {where(status: 1)}
validates_length_of :notes, maximum: 5000, message: "笔记不能超过5000个字"
end

@ -5,6 +5,7 @@ json.hack do
json.code @my_hack.code
json.pass_count @hack.pass_num
json.submit_count @hack.submit_num
json.notes @my_hack.notes
json.modify_code @modify
json.comments_count @hack.discusses.count
json.user_praise @hack.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0

@ -90,6 +90,7 @@ Rails.application.routes.draw do
get :submit_records
post :restore_initial_code
post :sync_code
post :add_notes
end
collection do

@ -0,0 +1,5 @@
class AddNotesHackUserLastestCodes < ActiveRecord::Migration[5.2]
def change
add_column :hack_user_lastest_codes, :notes, :longtext
end
end
Loading…
Cancel
Save