socialforge/app/controllers/works_controller.rb

64 lines
1.3 KiB
Ruby

class WorksController < ApplicationController
layout "base_contests"
before_filter :find_contest, :only => [:index,:new,:create]
before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:alert_open_student_works,:open_student_works]
before_filter :member_of_contest, :only => [:index]
def index
end
def show
end
def new
end
def create
end
def update
end
def edit
end
def destroy
end
private
#获取竞赛
def find_contest
@contest = Contest.find params[:contest]
rescue
render_404
end
#获取题目
def find_contestwork
@contestwork = Work.find params[:id]
@work_detail_group = @contestwork.work_detail_group
@contest = @contestwork.contest
rescue
render_404
end
#是不是管理员
def admin_of_contest
render_403 unless User.current.admin_of_contest?(@contest) || User.current.admin?
end
#当前用户是不是竞赛的成员
def member_of_contest
render_403 unless @contest.is_public==1 || User.current.member_of_contest?(@contest) || User.current.admin?
end
end