diff --git a/app/controllers/codejom_controller.rb b/app/controllers/codejom_controller.rb new file mode 100644 --- /dev/null +++ b/app/controllers/codejom_controller.rb @@ -0,0 +1,13 @@ +class CodejomController < ApplicationController + + before_filter :admin_authorization + before_filter :authenticate + + def index + @user = User.find(session[:user_id]) + @problems = Problem.find(:all) + @available_problems = @problems.find_all {|p| not p.available } + @activated_problems = @problems.find_all {|p| p.available } + end + +end diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -1,9 +1,10 @@ class StatusesController < ApplicationController - # protect the statuses, for now - before_filter :admin_authorization + def index + if not SHOW_CONTEST_STATUS + render :status => 403 and return + end - def index problem_count = Problem.available_problem_count @dead_users = [] @@ -22,6 +23,16 @@ @level_users[user.codejom_level] << user end end + + respond_to do |format| + format.html + format.xml do + render :xml => { + :levels => @level_users, + :dead_users => @dead_users + } + end + end end end diff --git a/app/helpers/codejom_helper.rb b/app/helpers/codejom_helper.rb new file mode 100644 --- /dev/null +++ b/app/helpers/codejom_helper.rb @@ -0,0 +1,2 @@ +module CodejomHelper +end diff --git a/app/views/codejom/index.html.haml b/app/views/codejom/index.html.haml new file mode 100644 --- /dev/null +++ b/app/views/codejom/index.html.haml @@ -0,0 +1,11 @@ +%h1 Code Jom Control Panel + +%h2= "Available problems (#{@available_problems.length})" +%ul + - @available_problems.each do |problem| + %li= problem.name + +%h2= "Activated problems (#{@activated_problems.length})" +- @activated_problems.each do |problem| + = problem.name + diff --git a/config/environment.rb.SAMPLE b/config/environment.rb.SAMPLE --- a/config/environment.rb.SAMPLE +++ b/config/environment.rb.SAMPLE @@ -108,3 +108,4 @@ # -------------------- CODEJOM_MAX_ALIVE_LEVEL = 10 TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute +SHOW_CONTEST_STATUS = false diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ ActionController::Routing::Routes.draw do |map| map.resources :announcements map.resources :sites + map.resources :statuses # The priority is based upon order of creation: first created -> highest priority. diff --git a/test/functional/codejom_controller_test.rb b/test/functional/codejom_controller_test.rb new file mode 100644 --- /dev/null +++ b/test/functional/codejom_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class CodejomControllerTest < ActionController::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/test/unit/helpers/codejom_helper_test.rb b/test/unit/helpers/codejom_helper_test.rb new file mode 100644 --- /dev/null +++ b/test/unit/helpers/codejom_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CodejomHelperTest < ActionView::TestCase +end