diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 9569df779..5b03f77c6 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 32434ac33..35817f97b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 1d062e607..eff520ef6 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -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 diff --git a/app/models/shixun_modify.rb b/app/models/shixun_modify.rb index 1c7aed505..e92edbc1b 100644 --- a/app/models/shixun_modify.rb +++ b/app/models/shixun_modify.rb @@ -1,3 +1,4 @@ class ShixunModify < ActiveRecord::Base attr_accessible :myshixun_id, :shixun_id, :status + belongs_to :myshixun end