删除实训的时候一并删除shixun_modify记录
This commit is contained in:
parent
a9d556dc60
commit
b2b4b8cd32
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
class ShixunModify < ActiveRecord::Base
|
||||
attr_accessible :myshixun_id, :shixun_id, :status
|
||||
belongs_to :myshixun
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue