Description:
disabled unused actions from controllers, protected statuses display, more styling
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r241:ce50017c6bce - - 5 files changed: 12 inserted, 2 deleted

@@ -55,96 +55,99
55 @submission.source = params['file'].read
55 @submission.source = params['file'].read
56 @submission.source_filename = params['file'].original_filename
56 @submission.source_filename = params['file'].original_filename
57 end
57 end
58 @submission.submitted_at = Time.new.gmtime
58 @submission.submitted_at = Time.new.gmtime
59
59
60 if Configuration.time_limit_mode? and user.contest_finished?
60 if Configuration.time_limit_mode? and user.contest_finished?
61 @submission.errors.add_to_base "The contest is over."
61 @submission.errors.add_to_base "The contest is over."
62 prepare_list_information
62 prepare_list_information
63 render :action => 'list' and return
63 render :action => 'list' and return
64 end
64 end
65
65
66 if @submission.valid?
66 if @submission.valid?
67 if @submission.save == false
67 if @submission.save == false
68 flash[:notice] = 'Error saving your submission'
68 flash[:notice] = 'Error saving your submission'
69 elsif Task.create(:submission_id => @submission.id,
69 elsif Task.create(:submission_id => @submission.id,
70 :status => Task::STATUS_INQUEUE) == false
70 :status => Task::STATUS_INQUEUE) == false
71 flash[:notice] = 'Error adding your submission to task queue'
71 flash[:notice] = 'Error adding your submission to task queue'
72 end
72 end
73 else
73 else
74 prepare_list_information
74 prepare_list_information
75 render :action => 'list' and return
75 render :action => 'list' and return
76 end
76 end
77 redirect_to :action => 'list'
77 redirect_to :action => 'list'
78 end
78 end
79
79
80 def source
80 def source
81 submission = Submission.find(params[:id])
81 submission = Submission.find(params[:id])
82 if submission.user_id == session[:user_id]
82 if submission.user_id == session[:user_id]
83 send_data(submission.source,
83 send_data(submission.source,
84 {:filename => submission.download_filename,
84 {:filename => submission.download_filename,
85 :type => 'text/plain'})
85 :type => 'text/plain'})
86 else
86 else
87 flash[:notice] = 'Error viewing source'
87 flash[:notice] = 'Error viewing source'
88 redirect_to :action => 'list'
88 redirect_to :action => 'list'
89 end
89 end
90 end
90 end
91
91
92 def compiler_msg
92 def compiler_msg
93 @submission = Submission.find(params[:id])
93 @submission = Submission.find(params[:id])
94 if @submission.user_id == session[:user_id]
94 if @submission.user_id == session[:user_id]
95 render :action => 'compiler_msg', :layout => 'empty'
95 render :action => 'compiler_msg', :layout => 'empty'
96 else
96 else
97 flash[:notice] = 'Error viewing source'
97 flash[:notice] = 'Error viewing source'
98 redirect_to :action => 'list'
98 redirect_to :action => 'list'
99 end
99 end
100 end
100 end
101
101
102 def submission
102 def submission
103 + # protect the action for Code Jom
104 + redirect_to :action => 'list'
105 +
103 @user = User.find(session[:user_id])
106 @user = User.find(session[:user_id])
104 @problems = Problem.find_available_problems
107 @problems = Problem.find_available_problems
105 if params[:id]==nil
108 if params[:id]==nil
106 @problem = nil
109 @problem = nil
107 @submissions = nil
110 @submissions = nil
108 else
111 else
109 @problem = Problem.find_by_name(params[:id])
112 @problem = Problem.find_by_name(params[:id])
110 if not @problem.available
113 if not @problem.available
111 redirect_to :action => 'list'
114 redirect_to :action => 'list'
112 flash[:notice] = 'Error: submissions for that problem are not viewable.'
115 flash[:notice] = 'Error: submissions for that problem are not viewable.'
113 return
116 return
114 end
117 end
115 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
118 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
116 end
119 end
117 end
120 end
118
121
119 def result
122 def result
120 if !Configuration.show_grading_result
123 if !Configuration.show_grading_result
121 redirect_to :action => 'list' and return
124 redirect_to :action => 'list' and return
122 end
125 end
123 @user = User.find(session[:user_id])
126 @user = User.find(session[:user_id])
124 @submission = Submission.find(params[:id])
127 @submission = Submission.find(params[:id])
125 if @submission.user!=@user
128 if @submission.user!=@user
126 flash[:notice] = 'You are not allowed to view result of other users.'
129 flash[:notice] = 'You are not allowed to view result of other users.'
127 redirect_to :action => 'list' and return
130 redirect_to :action => 'list' and return
128 end
131 end
129 prepare_grading_result(@submission)
132 prepare_grading_result(@submission)
130 end
133 end
131
134
132 def load_output
135 def load_output
133 if !Configuration.show_grading_result or params[:num]==nil
136 if !Configuration.show_grading_result or params[:num]==nil
134 redirect_to :action => 'list' and return
137 redirect_to :action => 'list' and return
135 end
138 end
136 @user = User.find(session[:user_id])
139 @user = User.find(session[:user_id])
137 @submission = Submission.find(params[:id])
140 @submission = Submission.find(params[:id])
138 if @submission.user!=@user
141 if @submission.user!=@user
139 flash[:notice] = 'You are not allowed to view result of other users.'
142 flash[:notice] = 'You are not allowed to view result of other users.'
140 redirect_to :action => 'list' and return
143 redirect_to :action => 'list' and return
141 end
144 end
142 case_num = params[:num].to_i
145 case_num = params[:num].to_i
143 out_filename = output_filename(@user.login,
146 out_filename = output_filename(@user.login,
144 @submission.problem.name,
147 @submission.problem.name,
145 @submission.id,
148 @submission.id,
146 case_num)
149 case_num)
147 if !FileTest.exists?(out_filename)
150 if !FileTest.exists?(out_filename)
148 flash[:notice] = 'Output not found.'
151 flash[:notice] = 'Output not found.'
149 redirect_to :action => 'list' and return
152 redirect_to :action => 'list' and return
150 end
153 end
@@ -1,24 +1,27
1 class StatusesController < ApplicationController
1 class StatusesController < ApplicationController
2
2
3 + # protect the statuses, for now
4 + before_filter :admin_authorization
5 +
3 def index
6 def index
4 problem_count = Problem.available_problem_count
7 problem_count = Problem.available_problem_count
5
8
6 @dead_users = []
9 @dead_users = []
7 @level_users = {}
10 @level_users = {}
8 @levels = (0..CODEJOM_MAX_ALIVE_LEVEL)
11 @levels = (0..CODEJOM_MAX_ALIVE_LEVEL)
9 @levels.each { |l| @level_users[l] = [] }
12 @levels.each { |l| @level_users[l] = [] }
10 User.find(:all).each do |user|
13 User.find(:all).each do |user|
11 if user.codejom_status==nil
14 if user.codejom_status==nil
12 user.update_codejom_status
15 user.update_codejom_status
13 user.codejom_status(true) # reload
16 user.codejom_status(true) # reload
14 end
17 end
15
18
16 if not user.codejom_status.alive
19 if not user.codejom_status.alive
17 @dead_users << user
20 @dead_users << user
18 else
21 else
19 @level_users[user.codejom_level] << user
22 @level_users[user.codejom_level] << user
20 end
23 end
21 end
24 end
22 end
25 end
23
26
24 end
27 end
@@ -1,50 +1,53
1 class TestController < ApplicationController
1 class TestController < ApplicationController
2
2
3 + # this page is unavailable in Code Jom
4 + before_filter :admin_authorization
5 +
3 before_filter :authenticate, :check_viewability
6 before_filter :authenticate, :check_viewability
4
7
5 #
8 #
6 # COMMENT OUT: filter in each action instead
9 # COMMENT OUT: filter in each action instead
7 #
10 #
8 # before_filter :verify_time_limit, :only => [:submit]
11 # before_filter :verify_time_limit, :only => [:submit]
9
12
10 verify :method => :post, :only => [:submit],
13 verify :method => :post, :only => [:submit],
11 :redirect_to => { :action => :index }
14 :redirect_to => { :action => :index }
12
15
13 def index
16 def index
14 prepare_index_information
17 prepare_index_information
15 end
18 end
16
19
17 def submit
20 def submit
18 @user = User.find(session[:user_id])
21 @user = User.find(session[:user_id])
19
22
20 @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request])
23 @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request])
21
24
22 if @submitted_test_request.errors.length != 0
25 if @submitted_test_request.errors.length != 0
23 prepare_index_information
26 prepare_index_information
24 render :action => 'index' and return
27 render :action => 'index' and return
25 end
28 end
26
29
27 if Configuration.time_limit_mode?
30 if Configuration.time_limit_mode?
28 if @user.contest_finished?
31 if @user.contest_finished?
29 @submitted_test_request.errors.add_to_base('Contest is over.')
32 @submitted_test_request.errors.add_to_base('Contest is over.')
30 prepare_index_information
33 prepare_index_information
31 render :action => 'index' and return
34 render :action => 'index' and return
32 end
35 end
33
36
34 if !Configuration.allow_test_request(@user)
37 if !Configuration.allow_test_request(@user)
35 prepare_index_information
38 prepare_index_information
36 flash[:notice] = 'Test request is not allowed during the last 30 minutes'
39 flash[:notice] = 'Test request is not allowed during the last 30 minutes'
37 redirect_to :action => 'index' and return
40 redirect_to :action => 'index' and return
38 end
41 end
39 end
42 end
40
43
41 if @submitted_test_request.save
44 if @submitted_test_request.save
42 redirect_to :action => 'index'
45 redirect_to :action => 'index'
43 else
46 else
44 prepare_index_information
47 prepare_index_information
45 render :action => 'index'
48 render :action => 'index'
46 end
49 end
47 end
50 end
48
51
49 def read
52 def read
50 user = User.find(session[:user_id])
53 user = User.find(session[:user_id])
@@ -1,8 +1,8
1 .problem-bar{:id => "problem-bar-#{problem.id}"}
1 .problem-bar{:id => "problem-bar-#{problem.id}"}
2 %a{:href => "#", :onclick => "$$('.problem-panel').each(function(elt) {elt.hide();}); $('problem-panel-#{problem.id}').show(); $('problem-panel-filler').hide(); return false;"}
2 %a{:href => "#", :onclick => "$$('.problem-panel').each(function(elt) {elt.hide();}); $('problem-panel-#{problem.id}').show(); $('problem-panel-filler').hide(); return false;"}
3 %span{:class => 'problem-title'}
3 %span{:class => 'problem-title'}
4 - = "#{problem.full_name} (#{problem.name})"
4 + = "#{problem.full_name}"
5 - if @prob_submissions[problem_title_counter][:count] > 0
5 - if @prob_submissions[problem_title_counter][:count] > 0
6 = "[#{@prob_submissions[problem_title_counter][:count]} trials(s)]"
6 = "[#{@prob_submissions[problem_title_counter][:count]} trials(s)]"
7 - else
7 - else
8 [No trials]
8 [No trials]
@@ -1,37 +1,38
1 - content_for :head do
1 - content_for :head do
2 = javascript_include_tag :defaults
2 = javascript_include_tag :defaults
3 = javascript_include_tag 'announcement_refresh.js'
3 = javascript_include_tag 'announcement_refresh.js'
4 = javascript_include_tag 'codejom_timeout.js'
4 = javascript_include_tag 'codejom_timeout.js'
5
5
6 = user_title_bar(@user)
6 = user_title_bar(@user)
7
7
8 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
8 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
9 %span{:class => 'title'}
9 %span{:class => 'title'}
10 Announcements
10 Announcements
11 #announcementbox-body
11 #announcementbox-body
12 = render :partial => 'announcement', :collection => @announcements
12 = render :partial => 'announcement', :collection => @announcements
13
13
14 %hr/
14 %hr/
15
15
16 - if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
16 - if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
17 %p=t 'main.start_soon'
17 %p=t 'main.start_soon'
18
18
19 - if Configuration.show_tasks_to?(@user)
19 - if Configuration.show_tasks_to?(@user)
20 .problem-list
20 .problem-list
21 = render :partial => 'problem_title', :collection => @problems, :as => :problem
21 = render :partial => 'problem_title', :collection => @problems, :as => :problem
22 .problem-content
22 .problem-content
23 %span{:id => "problem-panel-filler", :style => (@current_problem_id!=nil) ? "display:none" : ""}
23 %span{:id => "problem-panel-filler", :style => (@current_problem_id!=nil) ? "display:none" : ""}
24 - %b Welcome to Code Jom
24 + %h2
25 + Welcome to Code Jom
25 %br/
26 %br/
26 Choose problems from the list on the right.
27 Choose problems from the list on the right.
27 = render :partial => 'problem', :collection => @problems
28 = render :partial => 'problem', :collection => @problems
28
29
29 %br{:clear=>'both'}/
30 %br{:clear=>'both'}/
30 %hr/
31 %hr/
31
32
32 %script{:type => "text/javascript"}
33 %script{:type => "text/javascript"}
33 Announcement.registerRefreshEventTimer();
34 Announcement.registerRefreshEventTimer();
34 = render :partial => 'submission_timeouts'
35 = render :partial => 'submission_timeouts'
35 CodejomTimeout.updateProblemMessages();
36 CodejomTimeout.updateProblemMessages();
36 CodejomTimeout.registerRefreshEvent();
37 CodejomTimeout.registerRefreshEvent();
37
38
You need to be logged in to leave comments. Login now