实训添加重置功能
This commit is contained in:
parent
7a826e3461
commit
77025d0ae1
|
|
@ -3,7 +3,20 @@ class MyshixunsController < ApplicationController
|
|||
layout 'base_myshixun'
|
||||
skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
|
||||
before_filter :require_login, :except => [:training_task_status]
|
||||
before_filter :find_myshixun, :only => [:show]
|
||||
before_filter :find_myshixun, :only => [:show, :myshixun_reset]
|
||||
|
||||
def myshixun_reset
|
||||
ActiveRecord::Base.transaction do
|
||||
shixun = @myshixun.shixun
|
||||
@myshixun.destroy
|
||||
myshixun_member = @myshixun
|
||||
repository = @myshixun.repository
|
||||
repository.destroy
|
||||
git_rep = Gitlab.client.delete_project(@myshixun.gpid)
|
||||
|
||||
redirect_to shixun_exec_shixun_path(shixun)
|
||||
end
|
||||
end
|
||||
|
||||
# taskId 即返回的game id
|
||||
# 返回结果:params [:stauts] 0 表示成功,其它则失败
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class ShixunsController < ApplicationController
|
|||
else
|
||||
logger.error("res['code'] is #{res['code']}, res['msg'] is #{res['code']}")
|
||||
@jenkin_error = true
|
||||
raise("服务器异常,请联系系统管理员")
|
||||
raise("当前系统繁忙,请稍后再试")
|
||||
end
|
||||
rescue
|
||||
respond_to do |format|
|
||||
|
|
@ -162,6 +162,7 @@ class ShixunsController < ApplicationController
|
|||
generate_identifier
|
||||
m = ShixunMember.new(:user_id => User.current.id, :role => 1)
|
||||
@shixun.shixun_members << m
|
||||
# 自动构建版本库
|
||||
format.html { redirect_to shixun_path @shixun, notice: l(:notice_successful_create) }
|
||||
format.js
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ class Game < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :challenge
|
||||
has_many :outputs, :dependent => :destroy
|
||||
has_many :test_sets, :dependent => :destroy
|
||||
has_many :challenge_samples, :dependent => :destroy
|
||||
has_many :test_sets
|
||||
has_many :challenge_samples
|
||||
|
||||
# id 转换成 challenge'position
|
||||
def to_param
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# status 1:完成实训
|
||||
class Myshixun < ActiveRecord::Base
|
||||
attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier
|
||||
has_many :users, :through => :myshixun_members
|
||||
has_many :myshixun_members
|
||||
# has_many :users, :through => :myshixun_members
|
||||
has_many :myshixun_members, :dependent => :destroy
|
||||
has_one :repository
|
||||
has_many :games, :dependent => :destroy, :order => "games.id ASC"
|
||||
belongs_to :shixun
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="leftnav" style="position:fixed;bottom:0;">
|
||||
<%= link_to "重置", myshixun_reset_myshixun_path(@myshixun), :class => "leftnav-box-reset-inner font-12" %>
|
||||
<a href="<%= shixuns_path() %>" class="leftnav-box-inner" id="exit_task_tab" >
|
||||
<i class="fa fa-arrow-left font-20"></i><br/><span class="font-12">退出任务</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<% if @jenkin_error %>
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'shixuns/monitor_tip') %>";
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'shixuns/monitor_tip', :locals => {:result => false} )%>";
|
||||
pop_box_new(htmlvalue,460,406);
|
||||
<% else %>
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'shixuns/monitor_tip', :locals => {:result => true}) %>";
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
resources :myshixuns do
|
||||
member do
|
||||
|
||||
match 'myshixun_reset', :via => [:get, :post]
|
||||
end
|
||||
collection do
|
||||
match 'training_task_status', :via => [:get, :post]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ a.user-info-name{ display: block; font-size: 16px; color: #fff; max-width:100px;
|
|||
.leftnav-box{ width: 80px; height: 60px; background:#292b3a; padding:10px 0; margin-bottom:2px;}
|
||||
a.leftnav-box-inner{ display: block; width:77px; border-left:3px solid #292b3a; background:#292b3a; text-align: center; padding:10px 0; color:#575f6c;}
|
||||
a:hover.leftnav-box-inner,a.leftnav-active{border-left:3px solid #3498db;color: #fff!important;}
|
||||
a.leftnav-box-reset-inner{ display: block; width:77px; border-left:3px solid #292b3a; background:#292b3a; text-align: center; color:#575f6c;}
|
||||
a:hover.leftnav-box-reset-inner{border-left:3px solid #3498db;color: #fff!important;}
|
||||
.btn-cir{ background:#575f6c; color:#292b3a;display: inline-block; padding:0px 5px; border-radius:25px; border-radius:15px; line-height:20px; height: 20px; font-size:12px;}
|
||||
.btn-cir:hover{background:#fff;}
|
||||
.btn-cir-grey{background: #e1e1e1;color: #333;}
|
||||
|
|
|
|||
Loading…
Reference in New Issue