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

yslnewtiku
杨树林 5 years ago
commit c6c1a809f0

@ -61,7 +61,10 @@ class HackUserLastestCodesController < ApplicationController
# 提交记录
def submit_records
@records = @my_hack.hack_user_codes.created_order
records = @my_hack.hack_user_codes
@records_count = records.count
@records = paginate records.created_order
end

@ -131,13 +131,19 @@ class HacksController < ApplicationController
def new;end
def destroy
@hack.destroy
base_attrs = {
user_id: user_id, viewed: 0, tiding_type: 'System', trigger_user_id: current_user.id,
parent_container_type: "HackDelete"
}
@hack.tidings.create!(base_attrs)
render_ok
begin
base_attrs = {
user_id: @hack.user_id, viewed: 0, tiding_type: 'System', trigger_user_id: current_user.id,
parent_container_type: "HackDelete", extra: "#{@hack.name}"
}
@hack.tidings.create!(base_attrs)
@hack.destroy
render_ok
rescue => e
logger.error("####hack_delete_error: #{e.message}")
render_error("删除失败")
end
end
private

@ -412,6 +412,6 @@ module TidingDecorator
end
def hack_content
I18n.t(locale_format(parent_container_type)) % container&.name
I18n.t(locale_format(parent_container_type)) % (container&.name || extra)
end
end

@ -14,7 +14,7 @@ class Hack < ApplicationRecord
# 点赞
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
# 消息
has_many :tidings, as: :container, dependent: :destroy
has_many :tidings, as: :container
belongs_to :user

@ -1,6 +1,7 @@
class ShixunInfo < ApplicationRecord
belongs_to :shixun
validates_uniqueness_of :shixun_id
validates_length_of :fork_reason, maximum: 60
after_commit :create_diff_record
private

@ -1,4 +1,8 @@
json.array! @records do |hack_user|
json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory)
json.language hack_user.hack.language
end
json.records do
json.array! @records do |hack_user|
json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory)
json.language hack_user.hack.language
end
end
json.records_count @records_count
Loading…
Cancel
Save