权限控制,及修改获取当前任务的方法
This commit is contained in:
parent
3482ececf9
commit
c4ffa20461
|
@ -4,7 +4,7 @@ class GamesController < ApplicationController
|
|||
before_filter :find_myshixun, :only => [:index]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :game_status]
|
||||
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update]
|
||||
before_filter :allowd_manager, :only => [:game_build]
|
||||
before_filter :allowd_manager
|
||||
include ApplicationHelper
|
||||
|
||||
def index
|
||||
|
@ -165,7 +165,7 @@ class GamesController < ApplicationController
|
|||
end
|
||||
|
||||
def allowd_manager
|
||||
render_403 unless User.current.manager_of_myshixun?(@myshixun)
|
||||
render_403 unless (User.current.manager_of_myshixun?(@myshixun) || User.current.admin?)
|
||||
end
|
||||
|
||||
# Find myshixun of id params[:id]
|
||||
|
|
|
@ -6,12 +6,13 @@ class Myshixun < ActiveRecord::Base
|
|||
has_many :games, :dependent => :destroy, :order => "games.id ASC"
|
||||
|
||||
# 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录)
|
||||
# 优先取未完成的任务,如果任务都完成则取stage最大的任务(有下一步)
|
||||
# status:0 可以测评的,正在测评的
|
||||
# 如果都完成,则当前任务为最后一个任务
|
||||
def current_task
|
||||
games = self.games
|
||||
current_game = games.select{|game| game.status != 2 && game.status != 3}
|
||||
current_game = games.select{|game| game=[0,1]}.first
|
||||
if current_game.blank?
|
||||
current_game = Game.where(:status => 2, :myshixun_id => self.id).order("stage desc").first
|
||||
current_game = self.games.last
|
||||
end
|
||||
return current_game
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue