Description:
[web] fix time.new, time.now to use gmtime
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@249 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
r121:00c0c912cae9 - - 3 files changed: 3 inserted, 3 deleted
@@ -20,49 +20,49 | |||
|
20 | 20 | reset_session |
|
21 | 21 | flash[:notice] = saved_notice |
|
22 | 22 | |
|
23 | 23 | render :action => 'login', :layout => 'empty' |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | def list |
|
27 | 27 | prepare_list_information |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | 30 | def help |
|
31 | 31 | @user = User.find(session[:user_id]) |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def submit |
|
35 | 35 | user = User.find(session[:user_id]) |
|
36 | 36 | |
|
37 | 37 | @submission = Submission.new(params[:submission]) |
|
38 | 38 | @submission.user = user |
|
39 | 39 | @submission.language_id = 0 |
|
40 | 40 | if params['file']!='' |
|
41 | 41 | @submission.source = params['file'].read |
|
42 | 42 | @submission.source_filename = params['file'].original_filename |
|
43 | 43 | end |
|
44 | - @submission.submitted_at = Time.new | |
|
44 | + @submission.submitted_at = Time.new.gmtime | |
|
45 | 45 | |
|
46 | 46 | if user.site!=nil and user.site.finished? |
|
47 | 47 | @submission.errors.add_to_base "The contest is over." |
|
48 | 48 | prepare_list_information |
|
49 | 49 | render :action => 'list' and return |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | if @submission.valid? |
|
53 | 53 | if @submission.save == false |
|
54 | 54 | flash[:notice] = 'Error saving your submission' |
|
55 | 55 | elsif Task.create(:submission_id => @submission.id, |
|
56 | 56 | :status => Task::STATUS_INQUEUE) == false |
|
57 | 57 | flash[:notice] = 'Error adding your submission to task queue' |
|
58 | 58 | end |
|
59 | 59 | else |
|
60 | 60 | prepare_list_information |
|
61 | 61 | render :action => 'list' and return |
|
62 | 62 | end |
|
63 | 63 | redirect_to :action => 'list' |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | def source |
|
67 | 67 | submission = Submission.find(params[:id]) |
|
68 | 68 | if submission.user_id == session[:user_id] |
@@ -1,27 +1,27 | |||
|
1 | 1 | class Site < ActiveRecord::Base |
|
2 | 2 | |
|
3 | 3 | belongs_to :country |
|
4 | 4 | has_many :users |
|
5 | 5 | |
|
6 | 6 | def clear_start_time_if_not_started |
|
7 | 7 | if !self.started |
|
8 | 8 | self.start_time = nil |
|
9 | 9 | end |
|
10 | 10 | end |
|
11 | 11 | |
|
12 | 12 | def finished? |
|
13 | 13 | if !self.started |
|
14 | 14 | return false |
|
15 | 15 | end |
|
16 | 16 | |
|
17 | 17 | contest_time = Configuration['contest.time_limit'] |
|
18 | 18 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
19 | 19 | h = tmatch[1].to_i |
|
20 | 20 | m = tmatch[2].to_i |
|
21 | - return Time.now > (self.start_time + h.hour + m.minute) | |
|
21 | + return Time.now.gmtime > (self.start_time + h.hour + m.minute) | |
|
22 | 22 | else |
|
23 | 23 | false |
|
24 | 24 | end |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | end |
@@ -61,49 +61,49 | |||
|
61 | 61 | test_request.problem = problem |
|
62 | 62 | if problem!=nil |
|
63 | 63 | test_request.submission = |
|
64 | 64 | Submission.find_by_user_problem_number(user.id, |
|
65 | 65 | problem.id, |
|
66 | 66 | params[:submission_number]) |
|
67 | 67 | else |
|
68 | 68 | test_request.submission = nil |
|
69 | 69 | end |
|
70 | 70 | |
|
71 | 71 | # checks if the user submits any input file |
|
72 | 72 | if params[:input_file]==nil or params[:input_file]=="" |
|
73 | 73 | test_request.errors.add_to_base("No input submitted.") |
|
74 | 74 | test_request.input_file_name = nil |
|
75 | 75 | else |
|
76 | 76 | test_request.input_file_name = save_input_file(params[:input_file], user, problem) |
|
77 | 77 | if test_request.input_file_name == nil |
|
78 | 78 | test_request.errors.add_to_base("No input submitted.") |
|
79 | 79 | end |
|
80 | 80 | if params[:additional_file]!=nil and params[:additional_file]!="" |
|
81 | 81 | save_additional_file(params[:additional_file], |
|
82 | 82 | "#{test_request.input_file_name}.files") |
|
83 | 83 | end |
|
84 | 84 | end |
|
85 | - test_request.submitted_at = Time.new | |
|
85 | + test_request.submitted_at = Time.new.gmtime | |
|
86 | 86 | test_request.status_inqueue |
|
87 | 87 | test_request |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | protected |
|
91 | 91 | |
|
92 | 92 | def self.name_of(problem) |
|
93 | 93 | if problem!=nil |
|
94 | 94 | problem.name |
|
95 | 95 | else |
|
96 | 96 | "default" |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def self.random_input_file_name(user,problem) |
|
101 | 101 | problem_name = TestRequest.name_of(problem) |
|
102 | 102 | begin |
|
103 | 103 | tmpname = TEST_REQUEST_INPUT_FILE_DIR + "/#{user.login}/#{problem_name}/#{rand(10000)}" |
|
104 | 104 | end while File.exists?(tmpname) |
|
105 | 105 | tmpname |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def self.save_input_file(tempfile, user, problem) |
|
109 | 109 | new_file_name = random_input_file_name(user,problem) |
You need to be logged in to leave comments.
Login now