diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 0372976df..1816b032d 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -96,6 +96,12 @@ class GamesController < ApplicationController # Jupyter没有challenge @myshixun = Myshixun.find_by_identifier params[:identifier] @shixun = @myshixun.shixun + # 判断tpm是否修改了 + begin + @tpm_modified = @myshixun.repository_is_modified(@shixun.repo_path) # 判断TPM和TPI的版本库是否被改了 + rescue + uid_logger("实训平台繁忙,繁忙等级(81)") + end end def reset_vnc_link diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index b5c8af1f3..c9b027a1b 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -365,6 +365,31 @@ class MyshixunsController < ApplicationController end end + def sync_code + shixun_tomcat = edu_setting('cloud_bridge') + begin + git_myshixun_url = repo_ip_url @myshixun.repo_path + git_shixun_url = repo_ip_url @myshixun.shixun.try(:repo_path) + git_myshixun_url = Base64.urlsafe_encode64(git_myshixun_url) + git_shixun_url = Base64.urlsafe_encode64(git_shixun_url) + # todo: identifier 是以前的密码,用来验证的,新版如果不需要,和中间层协调更改. + params = {tpiID: "#{@myshixun.try(:id)}", tpiGitURL: "#{git_myshixun_url}", tpmGitURL: "#{git_shixun_url}", + identifier: "xinhu1ji2qu3"} + uri = "#{shixun_tomcat}/bridge/game/resetTpmRepository" + res = uri_post uri, params + if (res && res['code'] != 0) + tip_exception("实训云平台繁忙(繁忙等级:95)") + end + shixun_new_commit = GitService.commits(repo_path: @myshixun.shixun.repo_path).first["id"] + @myshixun.update_attributes!(commit_id: shixun_new_commit, reset_time: @myshixun.shixun.try(:reset_time)) + # 更新完成后,弹框则隐藏不再提示 + @myshixun.update_column(:system_tip, false) + render_ok + rescue Exception => e + tip_exception("立即更新代码失败!#{e.message}") + end + end + # -----End diff --git a/app/views/games/jupyter.json.jbuilder b/app/views/games/jupyter.json.jbuilder index 0714e9eca..94e43a24c 100644 --- a/app/views/games/jupyter.json.jbuilder +++ b/app/views/games/jupyter.json.jbuilder @@ -2,4 +2,6 @@ json.user do json.partial! 'users/user', user: current_user end -json.(@shixun, :id, :identifier, :status, :name) \ No newline at end of file +json.(@shixun, :id, :identifier, :status, :name) +json.myshixun_identifier @myshixun.identifier +json.tpm_modified @tpm_modified \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c6ced3bde..9b4da1338 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -183,6 +183,7 @@ Rails.application.routes.draw do post :html_content get :open_webssh get :challenges + post :sync_code end collection do get :sigle_mul_test