删除实训的时候一并删除shixun_modify记录

This commit is contained in:
huang 2017-06-23 16:14:20 +08:00
parent a9d556dc60
commit b2b4b8cd32
4 changed files with 18 additions and 0 deletions

View File

@ -192,6 +192,7 @@ class ShixunsController < ApplicationController
JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0)
@status = 1
end
shixun_modify_status_without_publish(@shixun, 1)
else
logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['code']}")
@jenkin_error = true

View File

@ -59,6 +59,21 @@ module ApplicationHelper
end
end
# 仅仅产生记录用于已执行publish的方法
def shixun_modify_status_without_publish shixun, type
myshixuns = shixun.myshixuns
unless myshixuns.blank?
myshixuns.each do |myshixun|
shixun_modify = ShixunModify.where(:shixun_id => shixun.id, :myshixun_id => myshixun.id).first
if shixun_modify.nil?
ShixunModify.create(:shixun_id => shixun.id, :myshixun_id => myshixun.id, :status => type)
else
shixun_modify.update_attribute(:status, type)
end
end
end
end
# 通关后,把最后一次成功的代码存到数据库
# type 0 创始内容, 1 最新内容
def game_passed_code game_id, path, myshixun_gpid, type

View File

@ -6,6 +6,7 @@ class Myshixun < ActiveRecord::Base
has_one :repository
has_many :games, :dependent => :destroy, :order => "games.id ASC"
belongs_to :shixun
has_one :shixun_modify, :dependent => :destroy
def total_stage
self.games.count

View File

@ -1,3 +1,4 @@
class ShixunModify < ActiveRecord::Base
attr_accessible :myshixun_id, :shixun_id, :status
belongs_to :myshixun
end