Description:
fix error message when submission to closed problem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r797:ebe6e5beb7c4 - - 5 files changed: 75 inserted, 75 deleted

@@ -1,44 +1,44
1 class SubmissionsController < ApplicationController
1 class SubmissionsController < ApplicationController
2 before_action :check_valid_login
2 before_action :check_valid_login
3 before_action :submission_authorization, only: [:show, :download, :edit]
3 before_action :submission_authorization, only: [:show, :download, :edit]
4 before_action :admin_authorization, only: [:rejudge]
4 before_action :admin_authorization, only: [:rejudge]
5
5
6 # GET /submissions
6 # GET /submissions
7 # GET /submissions.json
7 # GET /submissions.json
8 # Show problem selection and user's submission of that problem
8 # Show problem selection and user's submission of that problem
9 def index
9 def index
10 @user = @current_user
10 @user = @current_user
11 @problems = @user.available_problems
11 @problems = @user.available_problems
12
12
13 if params[:problem_id]==nil
13 if params[:problem_id]==nil
14 @problem = nil
14 @problem = nil
15 @submissions = nil
15 @submissions = nil
16 else
16 else
17 @problem = Problem.find_by_id(params[:problem_id])
17 @problem = Problem.find_by_id(params[:problem_id])
18 if (@problem == nil) or (not @problem.available)
18 if (@problem == nil) or (not @problem.available)
19 - redirect_to main_list_path
19 + redirect_to list_main_path
20 - flash[:notice] = 'Error: submissions for that problem are not viewable.'
20 + flash[:error] = 'Authorization error: You have no right to view submissions for this problem'
21 return
21 return
22 end
22 end
23 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id).order(id: :desc)
23 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id).order(id: :desc)
24 end
24 end
25 end
25 end
26
26
27 # GET /submissions/1
27 # GET /submissions/1
28 # GET /submissions/1.json
28 # GET /submissions/1.json
29 def show
29 def show
30 @submission = Submission.find(params[:id])
30 @submission = Submission.find(params[:id])
31
31
32 #log the viewing
32 #log the viewing
33 user = User.find(session[:user_id])
33 user = User.find(session[:user_id])
34 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
34 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
35
35
36 @task = @submission.task
36 @task = @submission.task
37 end
37 end
38
38
39 def download
39 def download
40 @submission = Submission.find(params[:id])
40 @submission = Submission.find(params[:id])
41 send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'})
41 send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'})
42 end
42 end
43
43
44 def compiler_msg
44 def compiler_msg
@@ -6,59 +6,61
6 redirect_to :action => 'list'
6 redirect_to :action => 'list'
7 end
7 end
8
8
9 def list
9 def list
10 @problems = @user.available_problems
10 @problems = @user.available_problems
11 end
11 end
12
12
13 # this has contest-wide access control
13 # this has contest-wide access control
14 def view
14 def view
15 base_name = params[:file]
15 base_name = params[:file]
16 base_filename = File.basename("#{base_name}.#{params[:ext]}")
16 base_filename = File.basename("#{base_name}.#{params[:ext]}")
17 filename = "#{Problem.download_file_basedir}/#{base_filename}"
17 filename = "#{Problem.download_file_basedir}/#{base_filename}"
18
18
19 if !FileTest.exists?(filename)
19 if !FileTest.exists?(filename)
20 redirect_to :action => 'index' and return
20 redirect_to :action => 'index' and return
21 end
21 end
22
22
23 send_file_to_user(filename, base_filename)
23 send_file_to_user(filename, base_filename)
24 end
24 end
25
25
26 # this has problem-level access control
26 # this has problem-level access control
27 def download
27 def download
28 problem = Problem.find(params[:id])
28 problem = Problem.find(params[:id])
29 unless @current_user.can_view_problem? problem
29 unless @current_user.can_view_problem? problem
30 - flash[:notice] = 'You are not authorized to access this file'
30 + flash[:error] = 'You are not authorized to access this file'
31 - redirect_to :action => 'index' and return
31 + redirect_to list_main_path
32 + return
32 end
33 end
33
34
34 base_name = params[:file]
35 base_name = params[:file]
35 base_filename = File.basename("#{base_name}.#{params[:ext]}")
36 base_filename = File.basename("#{base_name}.#{params[:ext]}")
36 filename = "#{Problem.download_file_basedir}/#{params[:id]}/#{base_filename}"
37 filename = "#{Problem.download_file_basedir}/#{params[:id]}/#{base_filename}"
37
38
38 if !FileTest.exists?(filename)
39 if !FileTest.exists?(filename)
39 flash[:notice] = 'File does not exists'
40 flash[:notice] = 'File does not exists'
40 - redirect_to :action => 'index' and return
41 + redirect_to list_main_path
42 + return
41 end
43 end
42
44
43 send_file_to_user(filename, base_filename)
45 send_file_to_user(filename, base_filename)
44 end
46 end
45
47
46 protected
48 protected
47
49
48 def send_file_to_user(filename, base_filename)
50 def send_file_to_user(filename, base_filename)
49 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
51 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
50 response.headers['Content-Type'] = "application/force-download"
52 response.headers['Content-Type'] = "application/force-download"
51 response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
53 response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
52 response.headers["X-Sendfile"] = filename
54 response.headers["X-Sendfile"] = filename
53 response.headers['Content-length'] = File.size(filename)
55 response.headers['Content-length'] = File.size(filename)
54 render :nothing => true
56 render :nothing => true
55 else
57 else
56 if params[:ext]=='pdf'
58 if params[:ext]=='pdf'
57 content_type = 'application/pdf'
59 content_type = 'application/pdf'
58 else
60 else
59 content_type = 'application/octet-stream'
61 content_type = 'application/octet-stream'
60 end
62 end
61
63
62 send_file filename, :stream => false, :disposition => 'inline', :filename => base_filename, :type => content_type
64 send_file filename, :stream => false, :disposition => 'inline', :filename => base_filename, :type => content_type
63 end
65 end
64 end
66 end
@@ -133,36 +133,36
133 end
133 end
134 end
134 end
135
135
136 # validation codes
136 # validation codes
137 def must_specify_language
137 def must_specify_language
138 return if self.source==nil
138 return if self.source==nil
139
139
140 # for output_only tasks
140 # for output_only tasks
141 return if self.problem!=nil and self.problem.output_only
141 return if self.problem!=nil and self.problem.output_only
142
142
143 if self.language == nil
143 if self.language == nil
144 errors.add('source',"Cannot detect language. Did you submit a correct source file?")
144 errors.add('source',"Cannot detect language. Did you submit a correct source file?")
145 end
145 end
146 end
146 end
147
147
148 def must_have_valid_problem
148 def must_have_valid_problem
149 return if self.source==nil
149 return if self.source==nil
150 if self.problem==nil
150 if self.problem==nil
151 errors.add('problem',"must be specified.")
151 errors.add('problem',"must be specified.")
152 else
152 else
153 #admin always have right
153 #admin always have right
154 return if self.user.admin?
154 return if self.user.admin?
155
155
156 #check if user has the right to submit the problem
156 #check if user has the right to submit the problem
157 - errors.add('problem',"must be valid.") if (!self.user.available_problems.include?(self.problem)) and (self.new_record?)
157 + errors[:base] << "Authorization error: you have no right to submit to this problem" if (!self.user.available_problems.include?(self.problem)) and (self.new_record?)
158 end
158 end
159 end
159 end
160
160
161 # callbacks
161 # callbacks
162 def assign_latest_number_if_new_recond
162 def assign_latest_number_if_new_recond
163 return if !self.new_record?
163 return if !self.new_record?
164 latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id)
164 latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id)
165 self.number = (latest==nil) ? 1 : latest.number + 1;
165 self.number = (latest==nil) ? 1 : latest.number + 1;
166 end
166 end
167
167
168 end
168 end
@@ -22,26 +22,26
22
22
23 %p
23 %p
24 =raw t 'help.accept_only_language_specified'
24 =raw t 'help.accept_only_language_specified'
25
25
26 %p
26 %p
27 =raw t 'help.specifying_task'
27 =raw t 'help.specifying_task'
28
28
29 %p
29 %p
30 =raw t 'help.example_cpp'
30 =raw t 'help.example_cpp'
31
31
32 %table{:border => '1'}
32 %table{:border => '1'}
33 %tr
33 %tr
34 %td{:width => '300px'}
34 %td{:width => '300px'}
35 %tt <tt>/*<br/>LANG: C++<br/>TASK: mobiles<br/>*/</tt>
35 %tt <tt>/*<br/>LANG: C++<br/>TASK: mobiles<br/>*/</tt>
36
36
37 %p
37 %p
38 =raw t 'help.example_pas'
38 =raw t 'help.example_pas'
39
39
40 %table{:border => '1'}
40 %table{:border => '1'}
41 %tr
41 %tr
42 %td{:width => '300px'}
42 %td{:width => '300px'}
43 %tt <tt>{<br/>LANG: Pascal<br/>TASK: mobiles<br/>}</tt>
43 %tt <tt>{<br/>LANG: Pascal<br/>TASK: mobiles<br/>}</tt>
44
44
45 %p
45 %p
46 - = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list')))
46 + = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),url: messages_path ))
47
47
@@ -1,310 +1,308
1 # This file is auto-generated from the current state of the database. Instead
1 # This file is auto-generated from the current state of the database. Instead
2 # of editing this file, please use the migrations feature of Active Record to
2 # of editing this file, please use the migrations feature of Active Record to
3 # incrementally modify your database, and then regenerate this schema definition.
3 # incrementally modify your database, and then regenerate this schema definition.
4 #
4 #
5 # Note that this schema.rb definition is the authoritative source for your
5 # Note that this schema.rb definition is the authoritative source for your
6 # database schema. If you need to create the application database on another
6 # database schema. If you need to create the application database on another
7 # system, you should be using db:schema:load, not running all the migrations
7 # system, you should be using db:schema:load, not running all the migrations
8 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 #
10 #
11 # It's strongly recommended that you check this file into your version control system.
11 # It's strongly recommended that you check this file into your version control system.
12
12
13 ActiveRecord::Schema.define(version: 2020_08_13_083020) do
13 ActiveRecord::Schema.define(version: 2020_08_13_083020) do
14
14
15 - create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
15 + create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
16 t.string "author"
16 t.string "author"
17 - t.text "body", limit: 16777215
17 + t.text "body"
18 t.boolean "published"
18 t.boolean "published"
19 - t.datetime "created_at", null: false
19 + t.datetime "created_at"
20 - t.datetime "updated_at", null: false
20 + t.datetime "updated_at"
21 t.boolean "frontpage", default: false
21 t.boolean "frontpage", default: false
22 t.boolean "contest_only", default: false
22 t.boolean "contest_only", default: false
23 t.string "title"
23 t.string "title"
24 t.string "notes"
24 t.string "notes"
25 end
25 end
26
26
27 - create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
27 + create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
28 t.string "title"
28 t.string "title"
29 t.boolean "enabled"
29 t.boolean "enabled"
30 - t.datetime "created_at", null: false
30 + t.datetime "created_at"
31 - t.datetime "updated_at", null: false
31 + t.datetime "updated_at"
32 t.string "name"
32 t.string "name"
33 end
33 end
34
34
35 - create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
35 + create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
36 t.integer "contest_id"
36 t.integer "contest_id"
37 t.integer "problem_id"
37 t.integer "problem_id"
38 end
38 end
39
39
40 - create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
40 + create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
41 t.integer "contest_id"
41 t.integer "contest_id"
42 t.integer "user_id"
42 t.integer "user_id"
43 end
43 end
44
44
45 - create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
45 + create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
46 t.string "name"
46 t.string "name"
47 - t.datetime "created_at", null: false
47 + t.datetime "created_at"
48 - t.datetime "updated_at", null: false
48 + t.datetime "updated_at"
49 end
49 end
50
50
51 - create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
51 + create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
52 - t.text "body", limit: 16777215
52 + t.text "body"
53 t.boolean "markdowned"
53 t.boolean "markdowned"
54 - t.datetime "created_at", null: false
54 + t.datetime "created_at"
55 - t.datetime "updated_at", null: false
55 + t.datetime "updated_at"
56 end
56 end
57
57
58 - create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
58 + create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
59 t.string "key"
59 t.string "key"
60 t.string "value_type"
60 t.string "value_type"
61 t.string "value"
61 t.string "value"
62 - t.datetime "created_at", null: false
62 + t.datetime "created_at"
63 - t.datetime "updated_at", null: false
63 + t.datetime "updated_at"
64 - t.text "description", limit: 16777215
64 + t.text "description"
65 end
65 end
66
66
67 - create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
67 + create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
68 t.string "host"
68 t.string "host"
69 t.integer "pid"
69 t.integer "pid"
70 t.string "mode"
70 t.string "mode"
71 t.boolean "active"
71 t.boolean "active"
72 - t.datetime "created_at", null: false
72 + t.datetime "created_at"
73 - t.datetime "updated_at", null: false
73 + t.datetime "updated_at"
74 t.integer "task_id"
74 t.integer "task_id"
75 t.string "task_type"
75 t.string "task_type"
76 t.boolean "terminated"
76 t.boolean "terminated"
77 - t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid"
77 + t.index ["host", "pid"], name: "index_grader_processes_on_host_and_pid"
78 end
78 end
79
79
80 create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
80 create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
81 t.string "name"
81 t.string "name"
82 t.string "description"
82 t.string "description"
83 t.boolean "enabled", default: true
83 t.boolean "enabled", default: true
84 end
84 end
85
85
86 create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
86 create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
87 t.integer "problem_id", null: false
87 t.integer "problem_id", null: false
88 t.integer "group_id", null: false
88 t.integer "group_id", null: false
89 t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id"
89 t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id"
90 end
90 end
91
91
92 - create_table "groups_users", options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
92 + create_table "groups_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
93 t.integer "group_id", null: false
93 t.integer "group_id", null: false
94 t.integer "user_id", null: false
94 t.integer "user_id", null: false
95 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
95 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
96 end
96 end
97
97
98 create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
98 create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
99 t.integer "user_id"
99 t.integer "user_id"
100 t.string "ip_address"
100 t.string "ip_address"
101 - t.datetime "created_at", null: false
101 + t.datetime "created_at"
102 - t.datetime "updated_at", null: false
102 + t.datetime "updated_at"
103 t.string "status"
103 t.string "status"
104 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
104 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
105 end
105 end
106
106
107 - create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
107 + create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
108 t.string "name", limit: 10
108 t.string "name", limit: 10
109 t.string "pretty_name"
109 t.string "pretty_name"
110 t.string "ext", limit: 10
110 t.string "ext", limit: 10
111 t.string "common_ext"
111 t.string "common_ext"
112 end
112 end
113
113
114 create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
114 create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
115 t.integer "user_id"
115 t.integer "user_id"
116 t.string "ip_address"
116 t.string "ip_address"
117 - t.datetime "created_at", null: false
117 + t.datetime "created_at"
118 - t.datetime "updated_at", null: false
118 + t.datetime "updated_at"
119 - t.index ["user_id"], name: "index_logins_on_user_id"
120 end
119 end
121
120
122 - create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
121 + create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
123 t.integer "sender_id"
122 t.integer "sender_id"
124 t.integer "receiver_id"
123 t.integer "receiver_id"
125 t.integer "replying_message_id"
124 t.integer "replying_message_id"
126 - t.text "body", limit: 16777215
125 + t.text "body"
127 t.boolean "replied"
126 t.boolean "replied"
128 - t.datetime "created_at", null: false
127 + t.datetime "created_at"
129 - t.datetime "updated_at", null: false
128 + t.datetime "updated_at"
130 end
129 end
131
130
132 - create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
131 + create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
133 - t.string "name", limit: 100
132 + t.string "name", limit: 30
134 t.string "full_name"
133 t.string "full_name"
135 t.integer "full_score"
134 t.integer "full_score"
136 t.date "date_added"
135 t.date "date_added"
137 t.boolean "available"
136 t.boolean "available"
138 t.string "url"
137 t.string "url"
139 t.integer "description_id"
138 t.integer "description_id"
140 t.boolean "test_allowed"
139 t.boolean "test_allowed"
141 t.boolean "output_only"
140 t.boolean "output_only"
142 t.string "description_filename"
141 t.string "description_filename"
143 t.boolean "view_testcase"
142 t.boolean "view_testcase"
144 end
143 end
145
144
146 create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
145 create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
147 t.integer "problem_id"
146 t.integer "problem_id"
148 t.integer "tag_id"
147 t.integer "tag_id"
149 t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true
148 t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true
150 t.index ["problem_id"], name: "index_problems_tags_on_problem_id"
149 t.index ["problem_id"], name: "index_problems_tags_on_problem_id"
151 t.index ["tag_id"], name: "index_problems_tags_on_tag_id"
150 t.index ["tag_id"], name: "index_problems_tags_on_tag_id"
152 end
151 end
153
152
154 - create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
153 + create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
155 t.string "name"
154 t.string "name"
156 t.string "controller"
155 t.string "controller"
157 t.string "action"
156 t.string "action"
158 end
157 end
159
158
160 - create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
159 + create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
161 t.integer "right_id"
160 t.integer "right_id"
162 t.integer "role_id"
161 t.integer "role_id"
163 t.index ["role_id"], name: "index_rights_roles_on_role_id"
162 t.index ["role_id"], name: "index_rights_roles_on_role_id"
164 end
163 end
165
164
166 - create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
165 + create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
167 t.string "name"
166 t.string "name"
168 end
167 end
169
168
170 - create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
169 + create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
171 t.integer "role_id"
170 t.integer "role_id"
172 t.integer "user_id"
171 t.integer "user_id"
173 t.index ["user_id"], name: "index_roles_users_on_user_id"
172 t.index ["user_id"], name: "index_roles_users_on_user_id"
174 end
173 end
175
174
176 - create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
175 + create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
177 t.string "session_id"
176 t.string "session_id"
178 - t.text "data", limit: 16777215
177 + t.text "data"
179 t.datetime "updated_at"
178 t.datetime "updated_at"
180 t.index ["session_id"], name: "index_sessions_on_session_id"
179 t.index ["session_id"], name: "index_sessions_on_session_id"
181 t.index ["updated_at"], name: "index_sessions_on_updated_at"
180 t.index ["updated_at"], name: "index_sessions_on_updated_at"
182 end
181 end
183
182
184 - create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
183 + create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
185 t.string "name"
184 t.string "name"
186 t.boolean "started"
185 t.boolean "started"
187 t.datetime "start_time"
186 t.datetime "start_time"
188 - t.datetime "created_at", null: false
187 + t.datetime "created_at"
189 - t.datetime "updated_at", null: false
188 + t.datetime "updated_at"
190 t.integer "country_id"
189 t.integer "country_id"
191 t.string "password"
190 t.string "password"
192 end
191 end
193
192
194 create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
193 create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
195 t.integer "user_id"
194 t.integer "user_id"
196 t.integer "submission_id"
195 t.integer "submission_id"
197 - t.datetime "created_at", null: false
196 + t.datetime "created_at"
198 - t.datetime "updated_at", null: false
197 + t.datetime "updated_at"
199 end
198 end
200
199
201 - create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
200 + create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
202 t.integer "user_id"
201 t.integer "user_id"
203 t.integer "problem_id"
202 t.integer "problem_id"
204 t.integer "language_id"
203 t.integer "language_id"
205 t.text "source", limit: 16777215
204 t.text "source", limit: 16777215
206 t.binary "binary"
205 t.binary "binary"
207 t.datetime "submitted_at"
206 t.datetime "submitted_at"
208 t.datetime "compiled_at"
207 t.datetime "compiled_at"
209 - t.text "compiler_message", limit: 16777215
208 + t.text "compiler_message"
210 t.datetime "graded_at"
209 t.datetime "graded_at"
211 t.integer "points"
210 t.integer "points"
212 - t.text "grader_comment", limit: 16777215
211 + t.text "grader_comment"
213 t.integer "number"
212 t.integer "number"
214 t.string "source_filename"
213 t.string "source_filename"
215 t.float "max_runtime"
214 t.float "max_runtime"
216 t.integer "peak_memory"
215 t.integer "peak_memory"
217 t.integer "effective_code_length"
216 t.integer "effective_code_length"
218 t.string "ip_address"
217 t.string "ip_address"
219 - t.index ["submitted_at"], name: "index_submissions_on_submitted_at"
220 t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
218 t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
221 t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
219 t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
222 end
220 end
223
221
224 create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
222 create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
225 t.string "name", null: false
223 t.string "name", null: false
226 t.text "description"
224 t.text "description"
227 t.boolean "public"
225 t.boolean "public"
228 t.datetime "created_at", null: false
226 t.datetime "created_at", null: false
229 t.datetime "updated_at", null: false
227 t.datetime "updated_at", null: false
230 end
228 end
231
229
232 - create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
230 + create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
233 t.integer "submission_id"
231 t.integer "submission_id"
234 t.datetime "created_at"
232 t.datetime "created_at"
235 t.integer "status"
233 t.integer "status"
236 t.datetime "updated_at"
234 t.datetime "updated_at"
237 t.index ["submission_id"], name: "index_tasks_on_submission_id"
235 t.index ["submission_id"], name: "index_tasks_on_submission_id"
238 end
236 end
239
237
240 - create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
238 + create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
241 t.integer "problem_id"
239 t.integer "problem_id"
242 - t.text "input", limit: 4294967295
240 + t.text "input", limit: 16777215
243 - t.text "solution", limit: 4294967295
241 + t.text "solution", limit: 16777215
244 - t.datetime "created_at", null: false
242 + t.datetime "created_at"
245 - t.datetime "updated_at", null: false
243 + t.datetime "updated_at"
246 end
244 end
247
245
248 - create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
246 + create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
249 t.integer "user_id"
247 t.integer "user_id"
250 t.integer "problem_id"
248 t.integer "problem_id"
251 t.integer "submission_id"
249 t.integer "submission_id"
252 t.string "input_file_name"
250 t.string "input_file_name"
253 t.string "output_file_name"
251 t.string "output_file_name"
254 t.string "running_stat"
252 t.string "running_stat"
255 t.integer "status"
253 t.integer "status"
256 - t.datetime "updated_at", null: false
254 + t.datetime "updated_at"
257 t.datetime "submitted_at"
255 t.datetime "submitted_at"
258 t.datetime "compiled_at"
256 t.datetime "compiled_at"
259 - t.text "compiler_message", limit: 16777215
257 + t.text "compiler_message"
260 t.datetime "graded_at"
258 t.datetime "graded_at"
261 t.string "grader_comment"
259 t.string "grader_comment"
262 - t.datetime "created_at", null: false
260 + t.datetime "created_at"
263 t.float "running_time"
261 t.float "running_time"
264 t.string "exit_status"
262 t.string "exit_status"
265 t.integer "memory_usage"
263 t.integer "memory_usage"
266 t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id"
264 t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id"
267 end
265 end
268
266
269 create_table "testcases", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
267 create_table "testcases", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
270 t.integer "problem_id"
268 t.integer "problem_id"
271 t.integer "num"
269 t.integer "num"
272 t.integer "group"
270 t.integer "group"
273 t.integer "score"
271 t.integer "score"
274 t.text "input", limit: 4294967295
272 t.text "input", limit: 4294967295
275 t.text "sol", limit: 4294967295
273 t.text "sol", limit: 4294967295
276 - t.datetime "created_at", null: false
274 + t.datetime "created_at"
277 - t.datetime "updated_at", null: false
275 + t.datetime "updated_at"
278 t.index ["problem_id"], name: "index_testcases_on_problem_id"
276 t.index ["problem_id"], name: "index_testcases_on_problem_id"
279 end
277 end
280
278
281 - create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
279 + create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
282 t.integer "user_id"
280 t.integer "user_id"
283 t.datetime "started_at"
281 t.datetime "started_at"
284 - t.datetime "created_at", null: false
282 + t.datetime "created_at"
285 - t.datetime "updated_at", null: false
283 + t.datetime "updated_at"
286 t.boolean "forced_logout"
284 t.boolean "forced_logout"
287 end
285 end
288
286
289 - create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
287 + create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
290 t.string "login", limit: 50
288 t.string "login", limit: 50
291 t.string "full_name"
289 t.string "full_name"
292 t.string "hashed_password"
290 t.string "hashed_password"
293 t.string "salt", limit: 5
291 t.string "salt", limit: 5
294 t.string "alias"
292 t.string "alias"
295 t.string "email"
293 t.string "email"
296 t.integer "site_id"
294 t.integer "site_id"
297 t.integer "country_id"
295 t.integer "country_id"
298 t.boolean "activated", default: false
296 t.boolean "activated", default: false
299 t.datetime "created_at"
297 t.datetime "created_at"
300 t.datetime "updated_at"
298 t.datetime "updated_at"
301 t.string "section"
299 t.string "section"
302 t.boolean "enabled", default: true
300 t.boolean "enabled", default: true
303 t.string "remark"
301 t.string "remark"
304 t.string "last_ip"
302 t.string "last_ip"
305 t.index ["login"], name: "index_users_on_login", unique: true
303 t.index ["login"], name: "index_users_on_login", unique: true
306 end
304 end
307
305
308 add_foreign_key "problems_tags", "problems"
306 add_foreign_key "problems_tags", "problems"
309 add_foreign_key "problems_tags", "tags"
307 add_foreign_key "problems_tags", "tags"
310 end
308 end
You need to be logged in to leave comments. Login now