Description:
- more test on user admin and authorization
- fix more routing
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r754:4cbf294c126c - - 8 files changed: 256 inserted, 195 deleted
@@ -60,4 +60,8 | |||
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | + def logout | |
|
64 | + redirect_to root_path | |
|
65 | + end | |
|
66 | + | |
|
63 | 67 | end |
@@ -21,6 +21,7 | |||
|
21 | 21 | redirect_to :action => 'login' |
|
22 | 22 | end |
|
23 | 23 | |
|
24 | + #reset login, clear session | |
|
24 | 25 | def login |
|
25 | 26 | saved_notice = flash[:notice] |
|
26 | 27 | reset_session |
@@ -40,6 +41,11 | |||
|
40 | 41 | render :action => 'login', :layout => 'empty' |
|
41 | 42 | end |
|
42 | 43 | |
|
44 | + def logout | |
|
45 | + reset_session | |
|
46 | + redirect_to root_path | |
|
47 | + end | |
|
48 | + | |
|
43 | 49 | def list |
|
44 | 50 | prepare_list_information |
|
45 | 51 | end |
@@ -21,8 +21,8 | |||
|
21 | 21 | - if GraderConfiguration.show_grading_result |
|
22 | 22 | = link_to '[detailed result]', :action => 'result', :id => submission.id |
|
23 | 23 | /= link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} |
|
24 |
- = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission |
|
|
25 |
- = link_to "#{t 'main.src_link'}", |
|
|
24 | + = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission), {popup: true,remote: true,class: 'btn btn-xs btn-info'} | |
|
25 | + = link_to "#{t 'main.src_link'}",download_submission_path(submission), class: 'btn btn-xs btn-info' | |
|
26 | 26 | = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info' |
|
27 | 27 | - if GraderConfiguration.show_testcase |
|
28 | 28 | = link_to "testcases", show_problem_testcases_path(problem_id), class: 'btn btn-xs btn-info' |
@@ -17,9 +17,9 | |||
|
17 | 17 | %hr |
|
18 | 18 | |
|
19 | 19 | = form_tag :action => 'grant_admin' do |
|
20 | - Grant admin permission to: | |
|
21 | - = text_field_tag 'login' | |
|
22 | - = submit_tag 'Grant' | |
|
20 | + = label_tag :login, 'Grant admin permission to:' | |
|
21 | + = text_field_tag 'login',nil, class: 'input-field' | |
|
22 | + = submit_tag 'Grant', class: 'btn btn-primary' | |
|
23 | 23 | |
|
24 | 24 | %hr/ |
|
25 | 25 | = link_to '[go back to index]', :action => 'index' |
@@ -7,11 +7,8 | |||
|
7 | 7 | #logins |
|
8 | 8 | match 'login/login', to: 'login#login', via: [:get,:post] |
|
9 | 9 | |
|
10 | - | |
|
11 | 10 | resources :contests |
|
12 | - | |
|
13 | 11 | resources :sites |
|
14 | - | |
|
15 | 12 | resources :test |
|
16 | 13 | |
|
17 | 14 | resources :messages do |
@@ -93,7 +90,7 | |||
|
93 | 90 | |
|
94 | 91 | |
|
95 | 92 | #user admin |
|
96 | - resources :user_admin do | |
|
93 | + resources :user_admin do | |
|
97 | 94 | collection do |
|
98 | 95 | match 'bulk_manage', via: [:get, :post] |
|
99 | 96 | get 'bulk_mail' |
@@ -103,6 +100,7 | |||
|
103 | 100 | get 'admin' |
|
104 | 101 | get 'active' |
|
105 | 102 | get 'mass_mailing' |
|
103 | + get 'revoke_admin' | |
|
106 | 104 | post 'grant_admin' |
|
107 | 105 | match 'create_from_list', via: [:get, :post] |
|
108 | 106 | match 'random_all_passwords', via: [:get, :post] |
@@ -144,11 +142,13 | |||
|
144 | 142 | #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' |
|
145 | 143 | |
|
146 | 144 | resource :main, only: [], controller: 'main' do |
|
145 | + get 'login' | |
|
146 | + get 'logout' | |
|
147 | 147 | get 'list' |
|
148 | 148 | get 'submission(/:id)', action: 'submission', as: 'main_submission' |
|
149 | - post 'submit' | |
|
150 | 149 | get 'announcements' |
|
151 | 150 | get 'help' |
|
151 | + post 'submit' | |
|
152 | 152 | end |
|
153 | 153 | #main |
|
154 | 154 | #get "main/list" |
@@ -1,4 +1,4 | |||
|
1 | - class ChangeSubmissionSourceSize < ActiveRecord::Migration | |
|
1 | + class ChangeSubmissionSourceSize < ActiveRecord::Migration[4.2] | |
|
2 | 2 | def change |
|
3 | 3 | change_column :submissions, :source, :text, :limit => 1.megabyte |
|
4 | 4 | end |
@@ -10,296 +10,295 | |||
|
10 | 10 | # |
|
11 | 11 | # It's strongly recommended that you check this file into your version control system. |
|
12 | 12 | |
|
13 | - ActiveRecord::Schema.define(version: 20180612102327) do | |
|
13 | + ActiveRecord::Schema.define(version: 2018_06_12_102327) do | |
|
14 | 14 | |
|
15 |
- create_table "announcements", |
|
|
16 |
- t.string |
|
|
17 | - t.text "body", limit: 65535 | |
|
18 |
- t.boolean |
|
|
15 | + create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
16 | + t.string "author" | |
|
17 | + t.text "body" | |
|
18 | + t.boolean "published" | |
|
19 | 19 | t.datetime "created_at" |
|
20 | 20 | t.datetime "updated_at" |
|
21 |
- t.boolean |
|
|
22 |
- t.boolean |
|
|
23 |
- t.string |
|
|
24 |
- t.string |
|
|
21 | + t.boolean "frontpage", default: false | |
|
22 | + t.boolean "contest_only", default: false | |
|
23 | + t.string "title" | |
|
24 | + t.string "notes" | |
|
25 | 25 | end |
|
26 | 26 | |
|
27 |
- create_table "contests", |
|
|
28 |
- t.string |
|
|
29 |
- t.boolean |
|
|
27 | + create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
28 | + t.string "title" | |
|
29 | + t.boolean "enabled" | |
|
30 | 30 | t.datetime "created_at" |
|
31 | 31 | t.datetime "updated_at" |
|
32 |
- t.string |
|
|
32 | + t.string "name" | |
|
33 | 33 | end |
|
34 | 34 | |
|
35 |
- create_table "contests_problems", id: false, force: :cascade |
|
|
35 | + create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
36 | 36 | t.integer "contest_id" |
|
37 | 37 | t.integer "problem_id" |
|
38 | 38 | end |
|
39 | 39 | |
|
40 |
- create_table "contests_users", id: false, force: :cascade |
|
|
40 | + create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
41 | 41 | t.integer "contest_id" |
|
42 | 42 | t.integer "user_id" |
|
43 | 43 | end |
|
44 | 44 | |
|
45 |
- create_table "countries", |
|
|
46 |
- t.string |
|
|
45 | + create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
46 | + t.string "name" | |
|
47 | 47 | t.datetime "created_at" |
|
48 | 48 | t.datetime "updated_at" |
|
49 | 49 | end |
|
50 | 50 | |
|
51 |
- create_table "descriptions", |
|
|
52 | - t.text "body", limit: 65535 | |
|
53 |
- t.boolean |
|
|
51 | + create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
52 | + t.text "body" | |
|
53 | + t.boolean "markdowned" | |
|
54 | 54 | t.datetime "created_at" |
|
55 | 55 | t.datetime "updated_at" |
|
56 | 56 | end |
|
57 | 57 | |
|
58 |
- create_table "grader_configurations", |
|
|
59 |
- t.string |
|
|
60 |
- t.string |
|
|
61 |
- t.string |
|
|
58 | + create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
59 | + t.string "key" | |
|
60 | + t.string "value_type" | |
|
61 | + t.string "value" | |
|
62 | 62 | t.datetime "created_at" |
|
63 | 63 | t.datetime "updated_at" |
|
64 |
- t.text |
|
|
64 | + t.text "description" | |
|
65 | 65 | end |
|
66 | 66 | |
|
67 |
- create_table "grader_processes", |
|
|
68 |
- t.string |
|
|
69 |
- t.integer |
|
|
70 |
- t.string |
|
|
71 |
- t.boolean |
|
|
67 | + create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
68 | + t.string "host" | |
|
69 | + t.integer "pid" | |
|
70 | + t.string "mode" | |
|
71 | + t.boolean "active" | |
|
72 | 72 | t.datetime "created_at" |
|
73 | 73 | t.datetime "updated_at" |
|
74 |
- t.integer |
|
|
75 |
- t.string |
|
|
76 |
- t.boolean |
|
|
77 |
- t.index ["host", "pid"], name: "index_grader_processes_on_ |
|
|
74 | + t.integer "task_id" | |
|
75 | + t.string "task_type" | |
|
76 | + t.boolean "terminated" | |
|
77 | + t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" | |
|
78 | 78 | end |
|
79 | 79 | |
|
80 |
- create_table "groups", |
|
|
80 | + create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
81 | 81 | t.string "name" |
|
82 | 82 | t.string "description" |
|
83 | 83 | end |
|
84 | 84 | |
|
85 |
- create_table "groups_problems", id: false, force: :cascade |
|
|
85 | + create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
86 | 86 | t.integer "problem_id", null: false |
|
87 |
- t.integer "group_id", |
|
|
88 |
- t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id" |
|
|
87 | + t.integer "group_id", null: false | |
|
88 | + t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id" | |
|
89 | 89 | end |
|
90 | 90 | |
|
91 |
- create_table "groups_users", id: false, force: :cascade |
|
|
91 | + create_table "groups_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
92 | 92 | t.integer "group_id", null: false |
|
93 |
- t.integer "user_id", |
|
|
94 |
- t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id" |
|
|
93 | + t.integer "user_id", null: false | |
|
94 | + t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id" | |
|
95 | 95 | end |
|
96 | 96 | |
|
97 |
- create_table "heart_beats", |
|
|
98 |
- t.integer |
|
|
99 |
- t.string |
|
|
100 | - t.datetime "created_at" | |
|
101 | - t.datetime "updated_at" | |
|
102 |
- t.string |
|
|
103 |
- t.index ["updated_at"], name: "index_heart_beats_on_updated_at" |
|
|
97 | + create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| | |
|
98 | + t.integer "user_id" | |
|
99 | + t.string "ip_address" | |
|
100 | + t.datetime "created_at", null: false | |
|
101 | + t.datetime "updated_at", null: false | |
|
102 | + t.string "status" | |
|
103 | + t.index ["updated_at"], name: "index_heart_beats_on_updated_at" | |
|
104 | 104 | end |
|
105 | 105 | |
|
106 |
- create_table "languages", |
|
|
107 |
- t.string "name", |
|
|
106 | + create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
107 | + t.string "name", limit: 10 | |
|
108 | 108 | t.string "pretty_name" |
|
109 |
- t.string "ext", |
|
|
109 | + t.string "ext", limit: 10 | |
|
110 | 110 | t.string "common_ext" |
|
111 | 111 | end |
|
112 | 112 | |
|
113 |
- create_table "logins", |
|
|
114 |
- t.integer |
|
|
115 |
- t.string |
|
|
113 | + create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| | |
|
114 | + t.integer "user_id" | |
|
115 | + t.string "ip_address" | |
|
116 | + t.datetime "created_at", null: false | |
|
117 | + t.datetime "updated_at", null: false | |
|
118 | + end | |
|
119 | + | |
|
120 | + create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
121 | + t.integer "sender_id" | |
|
122 | + t.integer "receiver_id" | |
|
123 | + t.integer "replying_message_id" | |
|
124 | + t.text "body" | |
|
125 | + t.boolean "replied" | |
|
116 | 126 | t.datetime "created_at" |
|
117 | 127 | t.datetime "updated_at" |
|
118 | 128 | end |
|
119 | 129 | |
|
120 |
- create_table " |
|
|
121 | - t.integer "sender_id" | |
|
122 | - t.integer "receiver_id" | |
|
123 | - t.integer "replying_message_id" | |
|
124 | - t.text "body", limit: 65535 | |
|
125 | - t.boolean "replied" | |
|
126 | - t.datetime "created_at" | |
|
127 | - t.datetime "updated_at" | |
|
128 | - end | |
|
129 | - | |
|
130 | - create_table "problems", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| | |
|
131 | - t.string "name", limit: 30 | |
|
132 | - t.string "full_name" | |
|
130 | + create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
131 | + t.string "name", limit: 30 | |
|
132 | + t.string "full_name" | |
|
133 | 133 | t.integer "full_score" |
|
134 |
- t.date |
|
|
134 | + t.date "date_added" | |
|
135 | 135 | t.boolean "available" |
|
136 |
- t.string |
|
|
136 | + t.string "url" | |
|
137 | 137 | t.integer "description_id" |
|
138 | 138 | t.boolean "test_allowed" |
|
139 | 139 | t.boolean "output_only" |
|
140 |
- t.string |
|
|
140 | + t.string "description_filename" | |
|
141 | 141 | t.boolean "view_testcase" |
|
142 | 142 | end |
|
143 | 143 | |
|
144 |
- create_table "problems_tags", |
|
|
144 | + create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
145 | 145 | t.integer "problem_id" |
|
146 | 146 | t.integer "tag_id" |
|
147 |
- t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true |
|
|
148 |
- t.index ["problem_id"], name: "index_problems_tags_on_problem_id" |
|
|
149 |
- t.index ["tag_id"], name: "index_problems_tags_on_tag_id" |
|
|
147 | + t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true | |
|
148 | + t.index ["problem_id"], name: "index_problems_tags_on_problem_id" | |
|
149 | + t.index ["tag_id"], name: "index_problems_tags_on_tag_id" | |
|
150 | 150 | end |
|
151 | 151 | |
|
152 |
- create_table "rights", |
|
|
152 | + create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
153 | 153 | t.string "name" |
|
154 | 154 | t.string "controller" |
|
155 | 155 | t.string "action" |
|
156 | 156 | end |
|
157 | 157 | |
|
158 |
- create_table "rights_roles", id: false, force: :cascade |
|
|
158 | + create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
159 | 159 | t.integer "right_id" |
|
160 | 160 | t.integer "role_id" |
|
161 |
- t.index ["role_id"], name: "index_rights_roles_on_role_id" |
|
|
161 | + t.index ["role_id"], name: "index_rights_roles_on_role_id" | |
|
162 | 162 | end |
|
163 | 163 | |
|
164 |
- create_table "roles", |
|
|
164 | + create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
165 | 165 | t.string "name" |
|
166 | 166 | end |
|
167 | 167 | |
|
168 |
- create_table "roles_users", id: false, force: :cascade |
|
|
168 | + create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
169 | 169 | t.integer "role_id" |
|
170 | 170 | t.integer "user_id" |
|
171 |
- t.index ["user_id"], name: "index_roles_users_on_user_id" |
|
|
171 | + t.index ["user_id"], name: "index_roles_users_on_user_id" | |
|
172 | 172 | end |
|
173 | 173 | |
|
174 |
- create_table "sessions", |
|
|
175 |
- t.string |
|
|
176 | - t.text "data", limit: 65535 | |
|
174 | + create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
175 | + t.string "session_id" | |
|
176 | + t.text "data" | |
|
177 | 177 | t.datetime "updated_at" |
|
178 |
- t.index ["session_id"], name: "index_sessions_on_session_id" |
|
|
179 |
- t.index ["updated_at"], name: "index_sessions_on_updated_at" |
|
|
178 | + t.index ["session_id"], name: "index_sessions_on_session_id" | |
|
179 | + t.index ["updated_at"], name: "index_sessions_on_updated_at" | |
|
180 | 180 | end |
|
181 | 181 | |
|
182 |
- create_table "sites", |
|
|
183 |
- t.string |
|
|
184 |
- t.boolean |
|
|
182 | + create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
183 | + t.string "name" | |
|
184 | + t.boolean "started" | |
|
185 | 185 | t.datetime "start_time" |
|
186 | 186 | t.datetime "created_at" |
|
187 | 187 | t.datetime "updated_at" |
|
188 |
- t.integer |
|
|
189 |
- t.string |
|
|
188 | + t.integer "country_id" | |
|
189 | + t.string "password" | |
|
190 | + end | |
|
191 | + | |
|
192 | + create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| | |
|
193 | + t.integer "user_id" | |
|
194 | + t.integer "submission_id" | |
|
195 | + t.datetime "created_at", null: false | |
|
196 | + t.datetime "updated_at", null: false | |
|
190 | 197 | end |
|
191 | 198 | |
|
192 |
- create_table "submission |
|
|
193 |
- t.integer |
|
|
194 |
- t.integer |
|
|
199 | + create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
200 | + t.integer "user_id" | |
|
201 | + t.integer "problem_id" | |
|
202 | + t.integer "language_id" | |
|
203 | + t.text "source", limit: 16777215 | |
|
204 | + t.binary "binary" | |
|
205 | + t.datetime "submitted_at" | |
|
206 | + t.datetime "compiled_at" | |
|
207 | + t.text "compiler_message" | |
|
208 | + t.datetime "graded_at" | |
|
209 | + t.integer "points" | |
|
210 | + t.text "grader_comment" | |
|
211 | + t.integer "number" | |
|
212 | + t.string "source_filename" | |
|
213 | + t.float "max_runtime" | |
|
214 | + t.integer "peak_memory" | |
|
215 | + t.integer "effective_code_length" | |
|
216 | + t.string "ip_address" | |
|
217 | + 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"], name: "index_submissions_on_user_id_and_problem_id" | |
|
219 | + end | |
|
220 | + | |
|
221 | + create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
222 | + t.string "name", null: false | |
|
223 | + t.text "description" | |
|
224 | + t.boolean "public" | |
|
225 | + t.datetime "created_at", null: false | |
|
226 | + t.datetime "updated_at", null: false | |
|
227 | + end | |
|
228 | + | |
|
229 | + create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
230 | + t.integer "submission_id" | |
|
231 | + t.datetime "created_at" | |
|
232 | + t.integer "status" | |
|
233 | + t.datetime "updated_at" | |
|
234 | + t.index ["submission_id"], name: "index_tasks_on_submission_id" | |
|
235 | + end | |
|
236 | + | |
|
237 | + create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
238 | + t.integer "problem_id" | |
|
239 | + t.text "input", limit: 16777215 | |
|
240 | + t.text "solution", limit: 16777215 | |
|
195 | 241 | t.datetime "created_at" |
|
196 | 242 | t.datetime "updated_at" |
|
197 | 243 | end |
|
198 | 244 | |
|
199 |
- create_table " |
|
|
200 |
- t.integer |
|
|
201 |
- t.integer |
|
|
202 |
- t.integer |
|
|
203 | - t.text "source", limit: 16777215 | |
|
204 | - t.binary "binary", limit: 65535 | |
|
245 | + create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
246 | + t.integer "user_id" | |
|
247 | + t.integer "problem_id" | |
|
248 | + t.integer "submission_id" | |
|
249 | + t.string "input_file_name" | |
|
250 | + t.string "output_file_name" | |
|
251 | + t.string "running_stat" | |
|
252 | + t.integer "status" | |
|
253 | + t.datetime "updated_at" | |
|
205 | 254 | t.datetime "submitted_at" |
|
206 | 255 | t.datetime "compiled_at" |
|
207 |
- t.text |
|
|
256 | + t.text "compiler_message" | |
|
208 | 257 | t.datetime "graded_at" |
|
209 | - t.integer "points" | |
|
210 | - t.text "grader_comment", limit: 65535 | |
|
211 | - t.integer "number" | |
|
212 | - t.string "source_filename" | |
|
213 | - t.float "max_runtime", limit: 24 | |
|
214 | - t.integer "peak_memory" | |
|
215 | - t.integer "effective_code_length" | |
|
216 | - t.string "ip_address" | |
|
217 | - t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree | |
|
218 | - t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree | |
|
258 | + t.string "grader_comment" | |
|
259 | + t.datetime "created_at" | |
|
260 | + t.float "running_time" | |
|
261 | + t.string "exit_status" | |
|
262 | + t.integer "memory_usage" | |
|
263 | + t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" | |
|
219 | 264 | end |
|
220 | 265 | |
|
221 |
- create_table "tags", force: :cascade |
|
|
222 | - t.string "name", null: false | |
|
223 | - t.text "description", limit: 65535 | |
|
224 | - t.boolean "public" | |
|
225 | - t.datetime "created_at", null: false | |
|
226 | - t.datetime "updated_at", null: false | |
|
266 | + create_table "testcases", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| | |
|
267 | + t.integer "problem_id" | |
|
268 | + t.integer "num" | |
|
269 | + t.integer "group" | |
|
270 | + t.integer "score" | |
|
271 | + t.text "input", limit: 4294967295 | |
|
272 | + t.text "sol", limit: 4294967295 | |
|
273 | + t.datetime "created_at" | |
|
274 | + t.datetime "updated_at" | |
|
275 | + t.index ["problem_id"], name: "index_testcases_on_problem_id" | |
|
227 | 276 | end |
|
228 | 277 | |
|
229 |
- create_table " |
|
|
230 |
- t.integer |
|
|
231 |
- t.datetime " |
|
|
232 | - t.integer "status" | |
|
233 | - t.datetime "updated_at" | |
|
234 | - t.index ["submission_id"], name: "index_tasks_on_submission_id", using: :btree | |
|
235 | - end | |
|
236 | - | |
|
237 | - create_table "test_pairs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| | |
|
238 | - t.integer "problem_id" | |
|
239 | - t.text "input", limit: 16777215 | |
|
240 | - t.text "solution", limit: 16777215 | |
|
278 | + create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
279 | + t.integer "user_id" | |
|
280 | + t.datetime "started_at" | |
|
241 | 281 | t.datetime "created_at" |
|
242 | 282 | t.datetime "updated_at" |
|
243 | 283 | end |
|
244 | 284 | |
|
245 |
- create_table " |
|
|
246 | - t.integer "user_id" | |
|
247 | - t.integer "problem_id" | |
|
248 | - t.integer "submission_id" | |
|
249 | - t.string "input_file_name" | |
|
250 |
- t.string |
|
|
251 |
- t.string |
|
|
252 |
- t.integer |
|
|
253 | - t.datetime "updated_at" | |
|
254 | - t.datetime "submitted_at" | |
|
255 | - t.datetime "compiled_at" | |
|
256 | - t.text "compiler_message", limit: 65535 | |
|
257 | - t.datetime "graded_at" | |
|
258 | - t.string "grader_comment" | |
|
259 | - t.datetime "created_at" | |
|
260 | - t.float "running_time", limit: 24 | |
|
261 | - t.string "exit_status" | |
|
262 | - t.integer "memory_usage" | |
|
263 | - t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree | |
|
264 | - end | |
|
265 | - | |
|
266 | - create_table "testcases", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| | |
|
267 | - t.integer "problem_id" | |
|
268 | - t.integer "num" | |
|
269 | - t.integer "group" | |
|
270 | - t.integer "score" | |
|
271 | - t.text "input", limit: 4294967295 | |
|
272 | - t.text "sol", limit: 4294967295 | |
|
285 | + create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| | |
|
286 | + t.string "login", limit: 50 | |
|
287 | + t.string "full_name" | |
|
288 | + t.string "hashed_password" | |
|
289 | + t.string "salt", limit: 5 | |
|
290 | + t.string "alias" | |
|
291 | + t.string "email" | |
|
292 | + t.integer "site_id" | |
|
293 | + t.integer "country_id" | |
|
294 | + t.boolean "activated", default: false | |
|
273 | 295 | t.datetime "created_at" |
|
274 | 296 | t.datetime "updated_at" |
|
275 | - t.index ["problem_id"], name: "index_testcases_on_problem_id", using: :btree | |
|
276 | - end | |
|
277 | - | |
|
278 | - create_table "user_contest_stats", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| | |
|
279 | - t.integer "user_id" | |
|
280 | - t.datetime "started_at" | |
|
281 | - t.datetime "created_at" | |
|
282 | - t.datetime "updated_at" | |
|
283 | - t.boolean "forced_logout" | |
|
284 | - end | |
|
285 | - | |
|
286 | - create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| | |
|
287 | - t.string "login", limit: 50 | |
|
288 | - t.string "full_name" | |
|
289 | - t.string "hashed_password" | |
|
290 | - t.string "salt", limit: 5 | |
|
291 | - t.string "alias" | |
|
292 | - t.string "email" | |
|
293 | - t.integer "site_id" | |
|
294 | - t.integer "country_id" | |
|
295 | - t.boolean "activated", default: false | |
|
296 | - t.datetime "created_at" | |
|
297 | - t.datetime "updated_at" | |
|
298 | - t.string "section" | |
|
299 | - t.boolean "enabled", default: true | |
|
300 | - t.string "remark" | |
|
301 | - t.string "last_ip" | |
|
302 | - t.index ["login"], name: "index_users_on_login", unique: true, using: :btree | |
|
297 | + t.string "section" | |
|
298 | + t.boolean "enabled", default: true | |
|
299 | + t.string "remark" | |
|
300 | + t.string "last_ip" | |
|
301 | + t.index ["login"], name: "index_users_on_login", unique: true | |
|
303 | 302 | end |
|
304 | 303 | |
|
305 | 304 | add_foreign_key "problems_tags", "problems" |
@@ -41,6 +41,58 | |||
|
41 | 41 | assert_text 'section 2' |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | + test "add multiple users" do | |
|
45 | + login 'admin', 'admin' | |
|
46 | + within 'header' do | |
|
47 | + click_on 'Manage' | |
|
48 | + click_on 'Users', match: :first | |
|
49 | + end | |
|
50 | + | |
|
51 | + click_on 'New list of users', match: :first | |
|
52 | + find(:css, 'textarea').fill_in with:"abc1,Boaty McBoatface,abcdef,alias1,remark1,\nabc2,Boaty2 McSecond,acbdef123,aias2,remark2" | |
|
53 | + click_on 'create users' | |
|
54 | + | |
|
55 | + assert_text('remark1') | |
|
56 | + assert_text('remark2') | |
|
57 | + end | |
|
58 | + | |
|
59 | + test "grant admin right" do | |
|
60 | + login 'admin', 'admin' | |
|
61 | + within 'header' do | |
|
62 | + click_on 'Manage' | |
|
63 | + click_on 'Users', match: :first | |
|
64 | + end | |
|
65 | + | |
|
66 | + click_on "View administrator" | |
|
67 | + fill_in 'login', with: 'john' | |
|
68 | + click_on "Grant" | |
|
69 | + | |
|
70 | + visit logout_main_path | |
|
71 | + login 'john','hello' | |
|
72 | + within 'header' do | |
|
73 | + click_on 'Manage' | |
|
74 | + click_on 'Problem', match: :first | |
|
75 | + end | |
|
76 | + assert_text "Turn off all problems" | |
|
77 | + end | |
|
78 | + | |
|
79 | + test "try using admin from normal user" do | |
|
80 | + login 'admin','admin' | |
|
81 | + visit bulk_manage_user_admin_index_path | |
|
82 | + assert_current_path bulk_manage_user_admin_index_path | |
|
83 | + visit logout_main_path | |
|
84 | + | |
|
85 | + login 'jack','morning' | |
|
86 | + visit bulk_manage_user_admin_index_path | |
|
87 | + assert_current_path root_path | |
|
88 | + assert_text 'You are not authorized' | |
|
89 | + | |
|
90 | + login 'james','morning' | |
|
91 | + visit new_list_user_admin_index_path | |
|
92 | + assert_current_path root_path | |
|
93 | + assert_text 'You are not authorized' | |
|
94 | + end | |
|
95 | + | |
|
44 | 96 | def login(username,password) |
|
45 | 97 | visit root_path |
|
46 | 98 | fill_in "Login", with: username |
You need to be logged in to leave comments.
Login now