Description:
added codejom controller, show status in public
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r254:dff48a9ca2cd - - 8 files changed: 54 inserted, 3 deleted
@@ -0,0 +1,13 | |||||
|
|
1 | + class CodejomController < ApplicationController | ||
|
|
2 | + | ||
|
|
3 | + before_filter :admin_authorization | ||
|
|
4 | + before_filter :authenticate | ||
|
|
5 | + | ||
|
|
6 | + def index | ||
|
|
7 | + @user = User.find(session[:user_id]) | ||
|
|
8 | + @problems = Problem.find(:all) | ||
|
|
9 | + @available_problems = @problems.find_all {|p| not p.available } | ||
|
|
10 | + @activated_problems = @problems.find_all {|p| p.available } | ||
|
|
11 | + end | ||
|
|
12 | + | ||
|
|
13 | + end |
@@ -0,0 +1,11 | |||||
|
|
1 | + %h1 Code Jom Control Panel | ||
|
|
2 | + | ||
|
|
3 | + %h2= "Available problems (#{@available_problems.length})" | ||
|
|
4 | + %ul | ||
|
|
5 | + - @available_problems.each do |problem| | ||
|
|
6 | + %li= problem.name | ||
|
|
7 | + | ||
|
|
8 | + %h2= "Activated problems (#{@activated_problems.length})" | ||
|
|
9 | + - @activated_problems.each do |problem| | ||
|
|
10 | + = problem.name | ||
|
|
11 | + |
@@ -0,0 +1,8 | |||||
|
|
1 | + require 'test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class CodejomControllerTest < ActionController::TestCase | ||
|
|
4 | + # Replace this with your real tests. | ||
|
|
5 | + test "the truth" do | ||
|
|
6 | + assert true | ||
|
|
7 | + end | ||
|
|
8 | + end |
@@ -0,0 +1,4 | |||||
|
|
1 | + require 'test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class CodejomHelperTest < ActionView::TestCase | ||
|
|
4 | + end |
@@ -1,9 +1,10 | |||||
|
1 | class StatusesController < ApplicationController |
|
1 | class StatusesController < ApplicationController |
|
2 |
|
2 | ||
|
3 | - # protect the statuses, for now |
|
3 | + def index |
|
4 | - before_filter :admin_authorization |
|
4 | + if not SHOW_CONTEST_STATUS |
|
|
5 | + render :status => 403 and return | ||
|
|
6 | + end | ||
|
5 |
|
7 | ||
|
6 | - def index |
|
||
|
7 | problem_count = Problem.available_problem_count |
|
8 | problem_count = Problem.available_problem_count |
|
8 |
|
9 | ||
|
9 | @dead_users = [] |
|
10 | @dead_users = [] |
@@ -22,6 +23,16 | |||||
|
22 | @level_users[user.codejom_level] << user |
|
23 | @level_users[user.codejom_level] << user |
|
23 | end |
|
24 | end |
|
24 | end |
|
25 | end |
|
|
26 | + | ||
|
|
27 | + respond_to do |format| | ||
|
|
28 | + format.html | ||
|
|
29 | + format.xml do | ||
|
|
30 | + render :xml => { | ||
|
|
31 | + :levels => @level_users, | ||
|
|
32 | + :dead_users => @dead_users | ||
|
|
33 | + } | ||
|
|
34 | + end | ||
|
|
35 | + end | ||
|
25 | end |
|
36 | end |
|
26 |
|
37 | ||
|
27 | end |
|
38 | end |
@@ -108,3 +108,4 | |||||
|
108 | # -------------------- |
|
108 | # -------------------- |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
|
111 | + SHOW_CONTEST_STATUS = false |
@@ -1,6 +1,7 | |||||
|
1 | ActionController::Routing::Routes.draw do |map| |
|
1 | ActionController::Routing::Routes.draw do |map| |
|
2 | map.resources :announcements |
|
2 | map.resources :announcements |
|
3 | map.resources :sites |
|
3 | map.resources :sites |
|
|
4 | + map.resources :statuses | ||
|
4 |
|
5 | ||
|
5 | # The priority is based upon order of creation: first created -> highest priority. |
|
6 | # The priority is based upon order of creation: first created -> highest priority. |
|
6 |
|
7 |
You need to be logged in to leave comments.
Login now