next方法封装
This commit is contained in:
parent
c920582fff
commit
19456503da
|
@ -1,7 +1,7 @@
|
|||
class GamesController < ApplicationController
|
||||
layout "base_myshixun"
|
||||
before_filter :find_myshixun, :only => [:index, :game_build]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry]
|
||||
before_filter :find_myshixun, :only => [:index]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step]
|
||||
before_filter :find_repository, :only => [:show, :entry]
|
||||
before_filter :allowd_manager, :only => [:game_build]
|
||||
include ApplicationHelper
|
||||
|
@ -51,6 +51,13 @@ class GamesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 自动推送下一个任务
|
||||
def next_step
|
||||
shixun = @myshixun.parent
|
||||
position = @game.stage + 1
|
||||
challenge = Challenge.where(:shixun_id => shixun, :position => position).first
|
||||
end
|
||||
|
||||
private
|
||||
def entry_and_raw(is_raw)
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
|
|
|
@ -5,6 +5,12 @@ class Myshixun < ActiveRecord::Base
|
|||
has_one :repository
|
||||
has_many :games, :dependent => :destroy, :order => "games.id ASC"
|
||||
|
||||
def parent
|
||||
Shixun.find(self.parent_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def owner
|
||||
User.find(self.user_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<%= link_to "返回", shixun_path(@myshixun.parent_id), :target => "_blank" %>
|
||||
|
||||
<% @games.each do |game| %>
|
||||
<%= link_to game.subject, myshixun_game_path(game, :myshixun_id => @myshixun) %>
|
||||
</br>
|
||||
|
|
|
@ -119,7 +119,8 @@
|
|||
</div>
|
||||
<div class="content-submitbox">
|
||||
<a href="#" class="task-btn mb10 ">保存修改</a><br/>
|
||||
<a href="#" class="task-btn task-btn-green ">提交测评</a>
|
||||
<%= link_to "提交评测", {:controller => 'games', :action => "game_build", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
<%= link_to "下一步", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -65,6 +65,7 @@ RedmineApp::Application.routes.draw do
|
|||
resources :games do
|
||||
member do
|
||||
match 'game_build', :via => [:get, :post]
|
||||
match 'next_step', :via => [:get, :post]
|
||||
get 'entry'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue