Description:
added announcement to frontpage
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@290 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r151:2e9ddcc1b233 - - 7 files changed: 38 inserted, 5 deleted
@@ -1,285 +1,283 | |||||
|
1 | class MainController < ApplicationController |
|
1 | class MainController < ApplicationController |
|
2 |
|
2 | ||
|
3 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
3 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
4 |
|
4 | ||
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
7 |
|
7 | ||
|
8 | # |
|
8 | # |
|
9 | # COMMENT OUT: filter in each action instead |
|
9 | # COMMENT OUT: filter in each action instead |
|
10 | # |
|
10 | # |
|
11 | # before_filter :verify_time_limit, :only => [:submit] |
|
11 | # before_filter :verify_time_limit, :only => [:submit] |
|
12 |
|
12 | ||
|
13 | verify :method => :post, :only => [:submit], |
|
13 | verify :method => :post, :only => [:submit], |
|
14 | :redirect_to => { :action => :index } |
|
14 | :redirect_to => { :action => :index } |
|
15 |
|
15 | ||
|
16 | # COMMENT OUT, only need when having high load |
|
16 | # COMMENT OUT, only need when having high load |
|
17 | # caches_action :index, :login |
|
17 | # caches_action :index, :login |
|
18 |
|
18 | ||
|
19 | def index |
|
19 | def index |
|
20 | redirect_to :action => 'login' |
|
20 | redirect_to :action => 'login' |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | def login |
|
23 | def login |
|
24 | saved_notice = flash[:notice] |
|
24 | saved_notice = flash[:notice] |
|
25 | reset_session |
|
25 | reset_session |
|
26 | flash[:notice] = saved_notice |
|
26 | flash[:notice] = saved_notice |
|
27 |
|
27 | ||
|
28 | # |
|
28 | # |
|
29 | # These are for site administrator login |
|
29 | # These are for site administrator login |
|
30 | # |
|
30 | # |
|
31 | @countries = Country.find(:all, :include => :sites) |
|
31 | @countries = Country.find(:all, :include => :sites) |
|
32 | @country_select = @countries.collect { |c| [c.name, c.id] } |
|
32 | @country_select = @countries.collect { |c| [c.name, c.id] } |
|
33 |
|
33 | ||
|
34 | @country_select_with_all = [['Any',0]] |
|
34 | @country_select_with_all = [['Any',0]] |
|
35 | @countries.each do |country| |
|
35 | @countries.each do |country| |
|
36 | @country_select_with_all << [country.name, country.id] |
|
36 | @country_select_with_all << [country.name, country.id] |
|
37 | end |
|
37 | end |
|
38 |
|
38 | ||
|
39 | @site_select = [] |
|
39 | @site_select = [] |
|
40 | @countries.each do |country| |
|
40 | @countries.each do |country| |
|
41 | country.sites.each do |site| |
|
41 | country.sites.each do |site| |
|
42 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
42 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
43 | end |
|
43 | end |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
|
46 | + @announcements = Announcement.find_for_frontpage | ||
|
46 | render :action => 'login', :layout => 'empty' |
|
47 | render :action => 'login', :layout => 'empty' |
|
47 | end |
|
48 | end |
|
48 |
|
49 | ||
|
49 | def list |
|
50 | def list |
|
50 | prepare_list_information |
|
51 | prepare_list_information |
|
51 | end |
|
52 | end |
|
52 |
|
53 | ||
|
53 | def help |
|
54 | def help |
|
54 | @user = User.find(session[:user_id]) |
|
55 | @user = User.find(session[:user_id]) |
|
55 | end |
|
56 | end |
|
56 |
|
57 | ||
|
57 | def submit |
|
58 | def submit |
|
58 | user = User.find(session[:user_id]) |
|
59 | user = User.find(session[:user_id]) |
|
59 |
|
60 | ||
|
60 | @submission = Submission.new(params[:submission]) |
|
61 | @submission = Submission.new(params[:submission]) |
|
61 | @submission.user = user |
|
62 | @submission.user = user |
|
62 | @submission.language_id = 0 |
|
63 | @submission.language_id = 0 |
|
63 | if params['file']!='' |
|
64 | if params['file']!='' |
|
64 | @submission.source = params['file'].read |
|
65 | @submission.source = params['file'].read |
|
65 | @submission.source_filename = params['file'].original_filename |
|
66 | @submission.source_filename = params['file'].original_filename |
|
66 | end |
|
67 | end |
|
67 | @submission.submitted_at = Time.new.gmtime |
|
68 | @submission.submitted_at = Time.new.gmtime |
|
68 |
|
69 | ||
|
69 | if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and |
|
70 | if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and |
|
70 | user.site!=nil and user.site.finished? |
|
71 | user.site!=nil and user.site.finished? |
|
71 | @submission.errors.add_to_base "The contest is over." |
|
72 | @submission.errors.add_to_base "The contest is over." |
|
72 | prepare_list_information |
|
73 | prepare_list_information |
|
73 | render :action => 'list' and return |
|
74 | render :action => 'list' and return |
|
74 | end |
|
75 | end |
|
75 |
|
76 | ||
|
76 | if @submission.valid? |
|
77 | if @submission.valid? |
|
77 | if @submission.save == false |
|
78 | if @submission.save == false |
|
78 | flash[:notice] = 'Error saving your submission' |
|
79 | flash[:notice] = 'Error saving your submission' |
|
79 | elsif Task.create(:submission_id => @submission.id, |
|
80 | elsif Task.create(:submission_id => @submission.id, |
|
80 | :status => Task::STATUS_INQUEUE) == false |
|
81 | :status => Task::STATUS_INQUEUE) == false |
|
81 | flash[:notice] = 'Error adding your submission to task queue' |
|
82 | flash[:notice] = 'Error adding your submission to task queue' |
|
82 | end |
|
83 | end |
|
83 | else |
|
84 | else |
|
84 | prepare_list_information |
|
85 | prepare_list_information |
|
85 | render :action => 'list' and return |
|
86 | render :action => 'list' and return |
|
86 | end |
|
87 | end |
|
87 | redirect_to :action => 'list' |
|
88 | redirect_to :action => 'list' |
|
88 | end |
|
89 | end |
|
89 |
|
90 | ||
|
90 | def source |
|
91 | def source |
|
91 | submission = Submission.find(params[:id]) |
|
92 | submission = Submission.find(params[:id]) |
|
92 | if submission.user_id == session[:user_id] |
|
93 | if submission.user_id == session[:user_id] |
|
93 | if submission.problem.output_only |
|
94 | if submission.problem.output_only |
|
94 | fname = submission.source_filename |
|
95 | fname = submission.source_filename |
|
95 | else |
|
96 | else |
|
96 | fname = submission.problem.name + '.' + submission.language.ext |
|
97 | fname = submission.problem.name + '.' + submission.language.ext |
|
97 | end |
|
98 | end |
|
98 | send_data(submission.source, |
|
99 | send_data(submission.source, |
|
99 | {:filename => fname, |
|
100 | {:filename => fname, |
|
100 | :type => 'text/plain'}) |
|
101 | :type => 'text/plain'}) |
|
101 | else |
|
102 | else |
|
102 | flash[:notice] = 'Error viewing source' |
|
103 | flash[:notice] = 'Error viewing source' |
|
103 | redirect_to :action => 'list' |
|
104 | redirect_to :action => 'list' |
|
104 | end |
|
105 | end |
|
105 | end |
|
106 | end |
|
106 |
|
107 | ||
|
107 | def compiler_msg |
|
108 | def compiler_msg |
|
108 | @submission = Submission.find(params[:id]) |
|
109 | @submission = Submission.find(params[:id]) |
|
109 | if @submission.user_id == session[:user_id] |
|
110 | if @submission.user_id == session[:user_id] |
|
110 | render :action => 'compiler_msg', :layout => 'empty' |
|
111 | render :action => 'compiler_msg', :layout => 'empty' |
|
111 | else |
|
112 | else |
|
112 | flash[:notice] = 'Error viewing source' |
|
113 | flash[:notice] = 'Error viewing source' |
|
113 | redirect_to :action => 'list' |
|
114 | redirect_to :action => 'list' |
|
114 | end |
|
115 | end |
|
115 | end |
|
116 | end |
|
116 |
|
117 | ||
|
117 | def submission |
|
118 | def submission |
|
118 | @user = User.find(session[:user_id]) |
|
119 | @user = User.find(session[:user_id]) |
|
119 | @problems = Problem.find_available_problems |
|
120 | @problems = Problem.find_available_problems |
|
120 | if params[:id]==nil |
|
121 | if params[:id]==nil |
|
121 | @problem = nil |
|
122 | @problem = nil |
|
122 | @submissions = nil |
|
123 | @submissions = nil |
|
123 | else |
|
124 | else |
|
124 | @problem = Problem.find_by_name(params[:id]) |
|
125 | @problem = Problem.find_by_name(params[:id]) |
|
125 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
126 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
126 | end |
|
127 | end |
|
127 | end |
|
128 | end |
|
128 |
|
129 | ||
|
129 | def result |
|
130 | def result |
|
130 | if !Configuration.show_grading_result |
|
131 | if !Configuration.show_grading_result |
|
131 | redirect_to :action => 'list' and return |
|
132 | redirect_to :action => 'list' and return |
|
132 | end |
|
133 | end |
|
133 | @user = User.find(session[:user_id]) |
|
134 | @user = User.find(session[:user_id]) |
|
134 | @submission = Submission.find(params[:id]) |
|
135 | @submission = Submission.find(params[:id]) |
|
135 | if @submission.user!=@user |
|
136 | if @submission.user!=@user |
|
136 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
137 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
137 | redirect_to :action => 'list' and return |
|
138 | redirect_to :action => 'list' and return |
|
138 | end |
|
139 | end |
|
139 | prepare_grading_result(@submission) |
|
140 | prepare_grading_result(@submission) |
|
140 | end |
|
141 | end |
|
141 |
|
142 | ||
|
142 | def load_output |
|
143 | def load_output |
|
143 | if !Configuration.show_grading_result or params[:num]==nil |
|
144 | if !Configuration.show_grading_result or params[:num]==nil |
|
144 | redirect_to :action => 'list' and return |
|
145 | redirect_to :action => 'list' and return |
|
145 | end |
|
146 | end |
|
146 | @user = User.find(session[:user_id]) |
|
147 | @user = User.find(session[:user_id]) |
|
147 | @submission = Submission.find(params[:id]) |
|
148 | @submission = Submission.find(params[:id]) |
|
148 | if @submission.user!=@user |
|
149 | if @submission.user!=@user |
|
149 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
150 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
150 | redirect_to :action => 'list' and return |
|
151 | redirect_to :action => 'list' and return |
|
151 | end |
|
152 | end |
|
152 | case_num = params[:num].to_i |
|
153 | case_num = params[:num].to_i |
|
153 | out_filename = output_filename(@user.login, |
|
154 | out_filename = output_filename(@user.login, |
|
154 | @submission.problem.name, |
|
155 | @submission.problem.name, |
|
155 | @submission.id, |
|
156 | @submission.id, |
|
156 | case_num) |
|
157 | case_num) |
|
157 | if !FileTest.exists?(out_filename) |
|
158 | if !FileTest.exists?(out_filename) |
|
158 | flash[:notice] = 'Output not found.' |
|
159 | flash[:notice] = 'Output not found.' |
|
159 | redirect_to :action => 'list' and return |
|
160 | redirect_to :action => 'list' and return |
|
160 | end |
|
161 | end |
|
161 |
|
162 | ||
|
162 | response.headers['Content-Type'] = "application/force-download" |
|
163 | response.headers['Content-Type'] = "application/force-download" |
|
163 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
164 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
164 | response.headers["X-Sendfile"] = out_filename |
|
165 | response.headers["X-Sendfile"] = out_filename |
|
165 | response.headers['Content-length'] = File.size(out_filename) |
|
166 | response.headers['Content-length'] = File.size(out_filename) |
|
166 | render :nothing => true |
|
167 | render :nothing => true |
|
167 | end |
|
168 | end |
|
168 |
|
169 | ||
|
169 | def error |
|
170 | def error |
|
170 | @user = User.find(session[:user_id]) |
|
171 | @user = User.find(session[:user_id]) |
|
171 | end |
|
172 | end |
|
172 |
|
173 | ||
|
173 | protected |
|
174 | protected |
|
174 | def prepare_list_information |
|
175 | def prepare_list_information |
|
175 | @problems = Problem.find_available_problems |
|
176 | @problems = Problem.find_available_problems |
|
176 | @prob_submissions = Array.new |
|
177 | @prob_submissions = Array.new |
|
177 | @user = User.find(session[:user_id]) |
|
178 | @user = User.find(session[:user_id]) |
|
178 | @problems.each do |p| |
|
179 | @problems.each do |p| |
|
179 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
180 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
180 | if sub!=nil |
|
181 | if sub!=nil |
|
181 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
182 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
182 | else |
|
183 | else |
|
183 | @prob_submissions << { :count => 0, :submission => nil } |
|
184 | @prob_submissions << { :count => 0, :submission => nil } |
|
184 | end |
|
185 | end |
|
185 | end |
|
186 | end |
|
186 | - |
|
187 | + @announcements = Announcement.find_published |
|
187 | - @announcements = Announcement.find(:all, |
|
||
|
188 | - :conditions => "published = 1", |
|
||
|
189 | - :order => "created_at DESC") |
|
||
|
190 | end |
|
188 | end |
|
191 |
|
189 | ||
|
192 | def check_viewability |
|
190 | def check_viewability |
|
193 | @user = User.find(session[:user_id]) |
|
191 | @user = User.find(session[:user_id]) |
|
194 | if (!Configuration.show_tasks_to?(@user)) and |
|
192 | if (!Configuration.show_tasks_to?(@user)) and |
|
195 | ((action_name=='submission') or (action_name=='submit')) |
|
193 | ((action_name=='submission') or (action_name=='submit')) |
|
196 | redirect_to :action => 'list' and return |
|
194 | redirect_to :action => 'list' and return |
|
197 | end |
|
195 | end |
|
198 | end |
|
196 | end |
|
199 |
|
197 | ||
|
200 | def prepare_grading_result(submission) |
|
198 | def prepare_grading_result(submission) |
|
201 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
199 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
202 | @test_runs = [] |
|
200 | @test_runs = [] |
|
203 | if grading_info['testruns'].is_a? Integer |
|
201 | if grading_info['testruns'].is_a? Integer |
|
204 | trun_count = grading_info['testruns'] |
|
202 | trun_count = grading_info['testruns'] |
|
205 | trun_count.times do |i| |
|
203 | trun_count.times do |i| |
|
206 | @test_runs << [ read_grading_result(@user.login, |
|
204 | @test_runs << [ read_grading_result(@user.login, |
|
207 | submission.problem.name, |
|
205 | submission.problem.name, |
|
208 | submission.id, |
|
206 | submission.id, |
|
209 | i+1) ] |
|
207 | i+1) ] |
|
210 | end |
|
208 | end |
|
211 | else |
|
209 | else |
|
212 | grading_info['testruns'].keys.sort.each do |num| |
|
210 | grading_info['testruns'].keys.sort.each do |num| |
|
213 | run = [] |
|
211 | run = [] |
|
214 | testrun = grading_info['testruns'][num] |
|
212 | testrun = grading_info['testruns'][num] |
|
215 | testrun.each do |c| |
|
213 | testrun.each do |c| |
|
216 | run << read_grading_result(@user.login, |
|
214 | run << read_grading_result(@user.login, |
|
217 | submission.problem.name, |
|
215 | submission.problem.name, |
|
218 | submission.id, |
|
216 | submission.id, |
|
219 | c) |
|
217 | c) |
|
220 | end |
|
218 | end |
|
221 | @test_runs << run |
|
219 | @test_runs << run |
|
222 | end |
|
220 | end |
|
223 | end |
|
221 | end |
|
224 | end |
|
222 | end |
|
225 |
|
223 | ||
|
226 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
224 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
227 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
225 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
228 | end |
|
226 | end |
|
229 |
|
227 | ||
|
230 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
228 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
231 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
229 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
232 | return "#{dir}/output.txt" |
|
230 | return "#{dir}/output.txt" |
|
233 | end |
|
231 | end |
|
234 |
|
232 | ||
|
235 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
233 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
236 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
234 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
237 | result_file_name = "#{dir}/result" |
|
235 | result_file_name = "#{dir}/result" |
|
238 | if !FileTest.exists?(result_file_name) |
|
236 | if !FileTest.exists?(result_file_name) |
|
239 | return {:num => case_num, :msg => 'program did not run'} |
|
237 | return {:num => case_num, :msg => 'program did not run'} |
|
240 | else |
|
238 | else |
|
241 | results = File.open(result_file_name).readlines |
|
239 | results = File.open(result_file_name).readlines |
|
242 | run_stat = extract_running_stat(results) |
|
240 | run_stat = extract_running_stat(results) |
|
243 | output_filename = "#{dir}/output.txt" |
|
241 | output_filename = "#{dir}/output.txt" |
|
244 | if FileTest.exists?(output_filename) |
|
242 | if FileTest.exists?(output_filename) |
|
245 | output_file = true |
|
243 | output_file = true |
|
246 | output_size = File.size(output_filename) |
|
244 | output_size = File.size(output_filename) |
|
247 | else |
|
245 | else |
|
248 | output_file = false |
|
246 | output_file = false |
|
249 | output_size = 0 |
|
247 | output_size = 0 |
|
250 | end |
|
248 | end |
|
251 |
|
249 | ||
|
252 | return { |
|
250 | return { |
|
253 | :num => case_num, |
|
251 | :num => case_num, |
|
254 | :msg => results[0], |
|
252 | :msg => results[0], |
|
255 | :run_stat => run_stat, |
|
253 | :run_stat => run_stat, |
|
256 | :output => output_file, |
|
254 | :output => output_file, |
|
257 | :output_size => output_size |
|
255 | :output_size => output_size |
|
258 | } |
|
256 | } |
|
259 | end |
|
257 | end |
|
260 | end |
|
258 | end |
|
261 |
|
259 | ||
|
262 | # copied from grader/script/lib/test_request_helper.rb |
|
260 | # copied from grader/script/lib/test_request_helper.rb |
|
263 | def extract_running_stat(results) |
|
261 | def extract_running_stat(results) |
|
264 | running_stat_line = results[-1] |
|
262 | running_stat_line = results[-1] |
|
265 |
|
263 | ||
|
266 | # extract exit status line |
|
264 | # extract exit status line |
|
267 | run_stat = "" |
|
265 | run_stat = "" |
|
268 | if !(/[Cc]orrect/.match(results[0])) |
|
266 | if !(/[Cc]orrect/.match(results[0])) |
|
269 | run_stat = results[0].chomp |
|
267 | run_stat = results[0].chomp |
|
270 | else |
|
268 | else |
|
271 | run_stat = 'Program exited normally' |
|
269 | run_stat = 'Program exited normally' |
|
272 | end |
|
270 | end |
|
273 |
|
271 | ||
|
274 | logger.info "Stat line: #{running_stat_line}" |
|
272 | logger.info "Stat line: #{running_stat_line}" |
|
275 |
|
273 | ||
|
276 | # extract running time |
|
274 | # extract running time |
|
277 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
275 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
278 | seconds = (res[1].to_f + res[2].to_f) |
|
276 | seconds = (res[1].to_f + res[2].to_f) |
|
279 | time_stat = "Time used: #{seconds} sec." |
|
277 | time_stat = "Time used: #{seconds} sec." |
|
280 | else |
|
278 | else |
|
281 | seconds = nil |
|
279 | seconds = nil |
|
282 | time_stat = "Time used: n/a sec." |
|
280 | time_stat = "Time used: n/a sec." |
|
283 | end |
|
281 | end |
|
284 |
|
282 | ||
|
285 | # extract memory usage |
|
283 | # extract memory usage |
@@ -1,2 +1,15 | |||||
|
1 | class Announcement < ActiveRecord::Base |
|
1 | class Announcement < ActiveRecord::Base |
|
|
2 | + | ||
|
|
3 | + def self.find_published | ||
|
|
4 | + Announcement.find(:all, | ||
|
|
5 | + :conditions => "(published = 1) AND (frontpage = 0)", | ||
|
|
6 | + :order => "created_at DESC") | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def self.find_for_frontpage | ||
|
|
10 | + Announcement.find(:all, | ||
|
|
11 | + :conditions => "(published = 1) AND (frontpage = 1)", | ||
|
|
12 | + :order => "created_at DESC") | ||
|
|
13 | + end | ||
|
|
14 | + | ||
|
2 | end |
|
15 | end |
@@ -1,27 +1,32 | |||||
|
1 | <h1>Editing announcement</h1> |
|
1 | <h1>Editing announcement</h1> |
|
2 |
|
2 | ||
|
3 | <%= error_messages_for :announcement %> |
|
3 | <%= error_messages_for :announcement %> |
|
4 |
|
4 | ||
|
5 | <% form_for(@announcement) do |f| %> |
|
5 | <% form_for(@announcement) do |f| %> |
|
6 | <p> |
|
6 | <p> |
|
7 | <b>Body</b><br /> |
|
7 | <b>Body</b><br /> |
|
8 | <%= f.text_area :body %> |
|
8 | <%= f.text_area :body %> |
|
9 | </p> |
|
9 | </p> |
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Author</b><br /> |
|
12 | <b>Author</b><br /> |
|
13 | <%= f.text_field :author %> |
|
13 | <%= f.text_field :author %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
16 | <p> |
|
16 | <p> |
|
17 | <b>Published</b><br /> |
|
17 | <b>Published</b><br /> |
|
18 | <%= f.check_box :published %> |
|
18 | <%= f.check_box :published %> |
|
19 | </p> |
|
19 | </p> |
|
20 |
|
20 | ||
|
21 | <p> |
|
21 | <p> |
|
|
22 | + <b>Show on front page?</b><br /> | ||
|
|
23 | + <%= f.check_box :frontpage %> | ||
|
|
24 | + </p> | ||
|
|
25 | + | ||
|
|
26 | + <p> | ||
|
22 | <%= f.submit "Update" %> |
|
27 | <%= f.submit "Update" %> |
|
23 | </p> |
|
28 | </p> |
|
24 | <% end %> |
|
29 | <% end %> |
|
25 |
|
30 | ||
|
26 | <%= link_to 'Show', @announcement %> | |
|
31 | <%= link_to 'Show', @announcement %> | |
|
27 | <%= link_to 'Back', announcements_path %> |
|
32 | <%= link_to 'Back', announcements_path %> |
@@ -1,26 +1,31 | |||||
|
1 | <h1>New announcement</h1> |
|
1 | <h1>New announcement</h1> |
|
2 |
|
2 | ||
|
3 | <%= error_messages_for :announcement %> |
|
3 | <%= error_messages_for :announcement %> |
|
4 |
|
4 | ||
|
5 | <% form_for(@announcement) do |f| %> |
|
5 | <% form_for(@announcement) do |f| %> |
|
6 | <p> |
|
6 | <p> |
|
7 | <b>Body</b><br /> |
|
7 | <b>Body</b><br /> |
|
8 | <%= f.text_area :body %> |
|
8 | <%= f.text_area :body %> |
|
9 | </p> |
|
9 | </p> |
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Author</b><br /> |
|
12 | <b>Author</b><br /> |
|
13 | <%= f.text_field :author %> |
|
13 | <%= f.text_field :author %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
16 | <p> |
|
16 | <p> |
|
17 | <b>Published</b><br /> |
|
17 | <b>Published</b><br /> |
|
18 | <%= f.check_box :published %> |
|
18 | <%= f.check_box :published %> |
|
19 | </p> |
|
19 | </p> |
|
20 |
|
20 | ||
|
21 | <p> |
|
21 | <p> |
|
|
22 | + <b>Show on front page?</b><br /> | ||
|
|
23 | + <%= f.check_box :frontpage %> | ||
|
|
24 | + </p> | ||
|
|
25 | + | ||
|
|
26 | + <p> | ||
|
22 | <%= f.submit "Create" %> |
|
27 | <%= f.submit "Create" %> |
|
23 | </p> |
|
28 | </p> |
|
24 | <% end %> |
|
29 | <% end %> |
|
25 |
|
30 | ||
|
26 | <%= link_to 'Back', announcements_path %> |
|
31 | <%= link_to 'Back', announcements_path %> |
@@ -1,18 +1,23 | |||||
|
1 | <p> |
|
1 | <p> |
|
2 | <b>Author:</b> |
|
2 | <b>Author:</b> |
|
3 | <%=h @announcement.author %> |
|
3 | <%=h @announcement.author %> |
|
4 | </p> |
|
4 | </p> |
|
5 |
|
5 | ||
|
6 | <p> |
|
6 | <p> |
|
7 | <b>Body:</b> |
|
7 | <b>Body:</b> |
|
8 | <%=h @announcement.body %> |
|
8 | <%=h @announcement.body %> |
|
9 | </p> |
|
9 | </p> |
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Published:</b> |
|
12 | <b>Published:</b> |
|
13 | <%=h @announcement.published %> |
|
13 | <%=h @announcement.published %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
|
16 | + <p> | ||
|
|
17 | + <b>Show on front page:</b> | ||
|
|
18 | + <%=h @announcement.frontpage %> | ||
|
|
19 | + </p> | ||
|
|
20 | + | ||
|
16 |
|
21 | ||
|
17 | <%= link_to 'Edit', edit_announcement_path(@announcement) %> | |
|
22 | <%= link_to 'Edit', edit_announcement_path(@announcement) %> | |
|
18 | <%= link_to 'Back', announcements_path %> |
|
23 | <%= link_to 'Back', announcements_path %> |
@@ -1,56 +1,62 | |||||
|
1 | %h1= Configuration['ui.front.title'] |
|
1 | %h1= Configuration['ui.front.title'] |
|
2 |
|
2 | ||
|
|
3 | + - if @announcements.length!=0 | ||
|
|
4 | + .announcementbox | ||
|
|
5 | + %span{:class => 'title'} | ||
|
|
6 | + Announcements | ||
|
|
7 | + = render :partial => 'announcement', :collection => @announcements | ||
|
|
8 | + | ||
|
3 | %b= Configuration['ui.front.welcome_message'] |
|
9 | %b= Configuration['ui.front.welcome_message'] |
|
4 | %br/ |
|
10 | %br/ |
|
5 | Please login to see the problem list. |
|
11 | Please login to see the problem list. |
|
6 | %br/ |
|
12 | %br/ |
|
7 | %br/ |
|
13 | %br/ |
|
8 |
|
14 | ||
|
9 | - if flash[:notice] |
|
15 | - if flash[:notice] |
|
10 | %hr/ |
|
16 | %hr/ |
|
11 | %b= flash[:notice] |
|
17 | %b= flash[:notice] |
|
12 | %hr/ |
|
18 | %hr/ |
|
13 |
|
19 | ||
|
14 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
20 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
15 | - form_tag :controller => 'login', :action => 'login' do |
|
21 | - form_tag :controller => 'login', :action => 'login' do |
|
16 | %table |
|
22 | %table |
|
17 | %tr |
|
23 | %tr |
|
18 | %td{:align => "right"} Login: |
|
24 | %td{:align => "right"} Login: |
|
19 | %td= text_field_tag 'login' |
|
25 | %td= text_field_tag 'login' |
|
20 | %tr |
|
26 | %tr |
|
21 | %td{:align => "right"} Password: |
|
27 | %td{:align => "right"} Password: |
|
22 | %td= password_field_tag |
|
28 | %td= password_field_tag |
|
23 | = submit_tag 'Login' |
|
29 | = submit_tag 'Login' |
|
24 |
|
30 | ||
|
25 | %br/ |
|
31 | %br/ |
|
26 |
|
32 | ||
|
27 | - if Configuration['system.mode']=='contest' |
|
33 | - if Configuration['system.mode']=='contest' |
|
28 | %script{:type => 'text/javascript'} |
|
34 | %script{:type => 'text/javascript'} |
|
29 | var siteList = new Array(); |
|
35 | var siteList = new Array(); |
|
30 | - @countries.each do |country| |
|
36 | - @countries.each do |country| |
|
31 | = "siteList[#{country.id}] = new Array();" |
|
37 | = "siteList[#{country.id}] = new Array();" |
|
32 | - country.sites.each do |site| |
|
38 | - country.sites.each do |site| |
|
33 | = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" |
|
39 | = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" |
|
34 |
|
40 | ||
|
35 | var allSiteList = new Array(); |
|
41 | var allSiteList = new Array(); |
|
36 | - @site_select.each do |sel| |
|
42 | - @site_select.each do |sel| |
|
37 | = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" |
|
43 | = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" |
|
38 |
|
44 | ||
|
39 | %script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} |
|
45 | %script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} |
|
40 |
|
46 | ||
|
41 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
47 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
42 | %b For Site Administrator. |
|
48 | %b For Site Administrator. |
|
43 | %br/ |
|
49 | %br/ |
|
44 | Please select your country and site and login. |
|
50 | Please select your country and site and login. |
|
45 | - form_for :login, nil, :url => {:controller => 'login', :action => 'site_login'} do |f| |
|
51 | - form_for :login, nil, :url => {:controller => 'login', :action => 'site_login'} do |f| |
|
46 | Country: |
|
52 | Country: |
|
47 | = select :site_country, :id, @country_select_with_all, {}, {:onchange => "updateSiteList();", :onclick => "updateSiteList();" } |
|
53 | = select :site_country, :id, @country_select_with_all, {}, {:onchange => "updateSiteList();", :onclick => "updateSiteList();" } |
|
48 | Site: |
|
54 | Site: |
|
49 | = select :login, :site_id, @site_select |
|
55 | = select :login, :site_id, @site_select |
|
50 | %br/ |
|
56 | %br/ |
|
51 | Password: |
|
57 | Password: |
|
52 | = f.password_field :password |
|
58 | = f.password_field :password |
|
53 | = submit_tag "Site Administrator Login" |
|
59 | = submit_tag "Site Administrator Login" |
|
54 |
|
60 | ||
|
55 | %script{:type => 'text/javascript'} |
|
61 | %script{:type => 'text/javascript'} |
|
56 | updateSiteList(); |
|
62 | updateSiteList(); |
@@ -1,115 +1,116 | |||||
|
1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
3 | # then regenerate this schema definition. |
|
3 | # then regenerate this schema definition. |
|
4 | # |
|
4 | # |
|
5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | # |
|
9 | # |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
11 |
|
11 | ||
|
12 |
- ActiveRecord::Schema.define(:version => 20081 |
|
12 | + ActiveRecord::Schema.define(:version => 20081107145815) do |
|
13 |
|
13 | ||
|
14 | create_table "announcements", :force => true do |t| |
|
14 | create_table "announcements", :force => true do |t| |
|
15 | t.string "author" |
|
15 | t.string "author" |
|
16 | t.text "body" |
|
16 | t.text "body" |
|
17 | t.boolean "published" |
|
17 | t.boolean "published" |
|
18 | t.datetime "created_at" |
|
18 | t.datetime "created_at" |
|
19 | t.datetime "updated_at" |
|
19 | t.datetime "updated_at" |
|
|
20 | + t.boolean "frontpage", :default => false | ||
|
20 | end |
|
21 | end |
|
21 |
|
22 | ||
|
22 | create_table "configurations", :force => true do |t| |
|
23 | create_table "configurations", :force => true do |t| |
|
23 | t.string "key" |
|
24 | t.string "key" |
|
24 | t.string "value_type" |
|
25 | t.string "value_type" |
|
25 | t.string "value" |
|
26 | t.string "value" |
|
26 | t.datetime "created_at" |
|
27 | t.datetime "created_at" |
|
27 | t.datetime "updated_at" |
|
28 | t.datetime "updated_at" |
|
28 | end |
|
29 | end |
|
29 |
|
30 | ||
|
30 | create_table "countries", :force => true do |t| |
|
31 | create_table "countries", :force => true do |t| |
|
31 | t.string "name" |
|
32 | t.string "name" |
|
32 | t.datetime "created_at" |
|
33 | t.datetime "created_at" |
|
33 | t.datetime "updated_at" |
|
34 | t.datetime "updated_at" |
|
34 | end |
|
35 | end |
|
35 |
|
36 | ||
|
36 | create_table "descriptions", :force => true do |t| |
|
37 | create_table "descriptions", :force => true do |t| |
|
37 | t.text "body" |
|
38 | t.text "body" |
|
38 | t.boolean "markdowned" |
|
39 | t.boolean "markdowned" |
|
39 | t.datetime "created_at" |
|
40 | t.datetime "created_at" |
|
40 | t.datetime "updated_at" |
|
41 | t.datetime "updated_at" |
|
41 | end |
|
42 | end |
|
42 |
|
43 | ||
|
43 | create_table "grader_processes", :force => true do |t| |
|
44 | create_table "grader_processes", :force => true do |t| |
|
44 | t.string "host", :limit => 20 |
|
45 | t.string "host", :limit => 20 |
|
45 | t.integer "pid" |
|
46 | t.integer "pid" |
|
46 | t.string "mode" |
|
47 | t.string "mode" |
|
47 | t.boolean "active" |
|
48 | t.boolean "active" |
|
48 | t.datetime "created_at" |
|
49 | t.datetime "created_at" |
|
49 | t.datetime "updated_at" |
|
50 | t.datetime "updated_at" |
|
50 | t.integer "task_id" |
|
51 | t.integer "task_id" |
|
51 | t.string "task_type" |
|
52 | t.string "task_type" |
|
52 | end |
|
53 | end |
|
53 |
|
54 | ||
|
54 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
55 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
55 |
|
56 | ||
|
56 | create_table "languages", :force => true do |t| |
|
57 | create_table "languages", :force => true do |t| |
|
57 | t.string "name", :limit => 10 |
|
58 | t.string "name", :limit => 10 |
|
58 | t.string "pretty_name" |
|
59 | t.string "pretty_name" |
|
59 | t.string "ext", :limit => 10 |
|
60 | t.string "ext", :limit => 10 |
|
60 | end |
|
61 | end |
|
61 |
|
62 | ||
|
62 | create_table "messages", :force => true do |t| |
|
63 | create_table "messages", :force => true do |t| |
|
63 | t.integer "sender_id" |
|
64 | t.integer "sender_id" |
|
64 | t.integer "receiver_id" |
|
65 | t.integer "receiver_id" |
|
65 | t.integer "replying_message_id" |
|
66 | t.integer "replying_message_id" |
|
66 | t.text "body" |
|
67 | t.text "body" |
|
67 | t.boolean "replied" |
|
68 | t.boolean "replied" |
|
68 | t.datetime "created_at" |
|
69 | t.datetime "created_at" |
|
69 | t.datetime "updated_at" |
|
70 | t.datetime "updated_at" |
|
70 | end |
|
71 | end |
|
71 |
|
72 | ||
|
72 | create_table "problems", :force => true do |t| |
|
73 | create_table "problems", :force => true do |t| |
|
73 | t.string "name", :limit => 30 |
|
74 | t.string "name", :limit => 30 |
|
74 | t.string "full_name" |
|
75 | t.string "full_name" |
|
75 | t.integer "full_score" |
|
76 | t.integer "full_score" |
|
76 | t.date "date_added" |
|
77 | t.date "date_added" |
|
77 | t.boolean "available" |
|
78 | t.boolean "available" |
|
78 | t.string "url" |
|
79 | t.string "url" |
|
79 | t.integer "description_id" |
|
80 | t.integer "description_id" |
|
80 | t.boolean "test_allowed" |
|
81 | t.boolean "test_allowed" |
|
81 | t.boolean "output_only" |
|
82 | t.boolean "output_only" |
|
82 | end |
|
83 | end |
|
83 |
|
84 | ||
|
84 | create_table "rights", :force => true do |t| |
|
85 | create_table "rights", :force => true do |t| |
|
85 | t.string "name" |
|
86 | t.string "name" |
|
86 | t.string "controller" |
|
87 | t.string "controller" |
|
87 | t.string "action" |
|
88 | t.string "action" |
|
88 | end |
|
89 | end |
|
89 |
|
90 | ||
|
90 | create_table "rights_roles", :id => false, :force => true do |t| |
|
91 | create_table "rights_roles", :id => false, :force => true do |t| |
|
91 | t.integer "right_id" |
|
92 | t.integer "right_id" |
|
92 | t.integer "role_id" |
|
93 | t.integer "role_id" |
|
93 | end |
|
94 | end |
|
94 |
|
95 | ||
|
95 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
96 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
96 |
|
97 | ||
|
97 | create_table "roles", :force => true do |t| |
|
98 | create_table "roles", :force => true do |t| |
|
98 | t.string "name" |
|
99 | t.string "name" |
|
99 | end |
|
100 | end |
|
100 |
|
101 | ||
|
101 | create_table "roles_users", :id => false, :force => true do |t| |
|
102 | create_table "roles_users", :id => false, :force => true do |t| |
|
102 | t.integer "role_id" |
|
103 | t.integer "role_id" |
|
103 | t.integer "user_id" |
|
104 | t.integer "user_id" |
|
104 | end |
|
105 | end |
|
105 |
|
106 | ||
|
106 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
107 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
107 |
|
108 | ||
|
108 | create_table "sessions", :force => true do |t| |
|
109 | create_table "sessions", :force => true do |t| |
|
109 | t.string "session_id" |
|
110 | t.string "session_id" |
|
110 | t.text "data" |
|
111 | t.text "data" |
|
111 | t.datetime "updated_at" |
|
112 | t.datetime "updated_at" |
|
112 | end |
|
113 | end |
|
113 |
|
114 | ||
|
114 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
115 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
115 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
116 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
You need to be logged in to leave comments.
Login now