Description:
tags / problems
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r879:60919c3675f4 - - 13 files changed: 89 inserted, 106 deleted

@@ -191,12 +191,14
191 timeout
191 timeout
192 net-smtp (0.3.1)
192 net-smtp (0.3.1)
193 digest
193 digest
194 net-protocol
194 net-protocol
195 timeout
195 timeout
196 nio4r (2.5.8)
196 nio4r (2.5.8)
197 + nokogiri (1.13.8-x86_64-darwin)
198 + racc (~> 1.4)
197 nokogiri (1.13.8-x86_64-linux)
199 nokogiri (1.13.8-x86_64-linux)
198 racc (~> 1.4)
200 racc (~> 1.4)
199 popper_js (2.11.6)
201 popper_js (2.11.6)
200 public_suffix (5.0.0)
202 public_suffix (5.0.0)
201 puma (5.6.5)
203 puma (5.6.5)
202 nio4r (~> 2.0)
204 nio4r (~> 2.0)
@@ -264,12 +266,13
264 concurrent-ruby (~> 1.0)
266 concurrent-ruby (~> 1.0)
265 rack (> 1, < 3)
267 rack (> 1, < 3)
266 sprockets-rails (3.4.2)
268 sprockets-rails (3.4.2)
267 actionpack (>= 5.2)
269 actionpack (>= 5.2)
268 activesupport (>= 5.2)
270 activesupport (>= 5.2)
269 sprockets (>= 3.0.0)
271 sprockets (>= 3.0.0)
272 + sqlite3 (1.5.0-x86_64-darwin)
270 sqlite3 (1.5.0-x86_64-linux)
273 sqlite3 (1.5.0-x86_64-linux)
271 strscan (3.0.4)
274 strscan (3.0.4)
272 temple (0.8.2)
275 temple (0.8.2)
273 thor (1.2.1)
276 thor (1.2.1)
274 tilt (2.0.11)
277 tilt (2.0.11)
275 timeout (0.3.0)
278 timeout (0.3.0)
@@ -290,12 +293,13
290 websocket-extensions (0.1.5)
293 websocket-extensions (0.1.5)
291 xpath (3.2.0)
294 xpath (3.2.0)
292 nokogiri (~> 1.8)
295 nokogiri (~> 1.8)
293 zeitwerk (2.6.0)
296 zeitwerk (2.6.0)
294
297
295 PLATFORMS
298 PLATFORMS
299 + x86_64-darwin-20
296 x86_64-linux
300 x86_64-linux
297
301
298 DEPENDENCIES
302 DEPENDENCIES
299 ace-rails-ap
303 ace-rails-ap
300 best_in_place!
304 best_in_place!
301 bootsnap
305 bootsnap
@@ -12,15 +12,14
12 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
12 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
13 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
13 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
14 WHITELIST_IGNORE_CONF_KEY = 'right.whitelist_ignore'
14 WHITELIST_IGNORE_CONF_KEY = 'right.whitelist_ignore'
15 WHITELIST_IP_CONF_KEY = 'right.whitelist_ip'
15 WHITELIST_IP_CONF_KEY = 'right.whitelist_ip'
16
16
17 #report and redirect for unauthorized activities
17 #report and redirect for unauthorized activities
18 - def unauthorized_redirect(notice = 'You are not authorized to view the page you requested')
18 + def unauthorized_redirect(msg = 'You are not authorized to view the page you requested')
19 - flash[:notice] = notice
19 + redirect_to login_main_path, alert: msg
20 - redirect_to login_main_path
21 end
20 end
22
21
23 # Returns the current logged-in user (if any).
22 # Returns the current logged-in user (if any).
24 def current_user
23 def current_user
25 return nil unless session[:user_id]
24 return nil unless session[:user_id]
26 @current_user ||= User.find(session[:user_id])
25 @current_user ||= User.find(session[:user_id])
@@ -43,36 +42,24
43 unauthorized_redirect
42 unauthorized_redirect
44 return false
43 return false
45 end
44 end
46 return true
45 return true
47 end
46 end
48
47
49 - #admin always count as every roles
48 + def authorization_by_roles(allowed_roles)
50 - def role_authorization(roles)
51 return false unless check_valid_login
49 return false unless check_valid_login
52 - user = User.find(session[:user_id])
50 + return true if @current_user.admin?
53 - return true if user.admin?
54 roles.each do |r|
51 roles.each do |r|
55 - return true if user.has_role?(r)
52 + return true if @current_user.has_role?(r)
56 end
53 end
57 unauthorized_redirect
54 unauthorized_redirect
58 end
55 end
59
56
60 - def authorization_by_roles(allowed_roles)
61 - return false unless check_valid_login
62 - unless @current_user.roles.detect { |role| allowed_roles.member?(role.name) }
63 - unauthorized_redirect
64 - return false
65 - end
66 - end
67 -
68 def testcase_authorization
57 def testcase_authorization
69 #admin always has privileged
58 #admin always has privileged
70 - if @current_user.admin?
59 + return true if @current_user.admin?
71 - return true
72 - end
73
60
74 unauthorized_redirect unless GraderConfiguration["right.view_testcase"]
61 unauthorized_redirect unless GraderConfiguration["right.view_testcase"]
75 end
62 end
76
63
77 def unique_visitor_id
64 def unique_visitor_id
78 unless cookies.encrypted[:uuid]
65 unless cookies.encrypted[:uuid]
@@ -1,27 +1,25
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 @@authenticators = []
3 @@authenticators = []
4 -
4 +
5 def index
5 def index
6 # show login screen
6 # show login screen
7 reset_session
7 reset_session
8 redirect_to :controller => 'main', :action => 'login'
8 redirect_to :controller => 'main', :action => 'login'
9 end
9 end
10
10
11 def login
11 def login
12 user = get_authenticated_user(params[:login], params[:password])
12 user = get_authenticated_user(params[:login], params[:password])
13 unless user
13 unless user
14 - flash[:notice] = 'Wrong password'
14 + redirect_to login_main_path, alert: 'Wrong password'
15 - redirect_to :controller => 'main', :action => 'login'
16 return
15 return
17 end
16 end
18
17
19 if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree]) and !user.admin?
18 if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree]) and !user.admin?
20 - flash[:notice] = 'You must accept the agreement before logging in'
19 + redirect_to login_main_path, alert: 'You must accept the agreement before logging in'
21 - redirect_to :controller => 'main', :action => 'login'
22 return
20 return
23 end
21 end
24
22
25 #store uuid when login
23 #store uuid when login
26 if user.last_ip.nil?
24 if user.last_ip.nil?
27 user.last_ip = cookies.encrypted[:uuid]
25 user.last_ip = cookies.encrypted[:uuid]
@@ -57,20 +55,20
57 begin
55 begin
58 site = Site.find(params[:login][:site_id])
56 site = Site.find(params[:login][:site_id])
59 rescue ActiveRecord::RecordNotFound
57 rescue ActiveRecord::RecordNotFound
60 site = nil
58 site = nil
61 end
59 end
62 if site==nil
60 if site==nil
63 - flash[:notice] = 'Wrong site'
61 + flash[:alert] = 'Wrong site'
64 redirect_to :controller => 'main', :action => 'login' and return
62 redirect_to :controller => 'main', :action => 'login' and return
65 end
63 end
66 if (site.password) and (site.password == params[:login][:password])
64 if (site.password) and (site.password == params[:login][:password])
67 session[:site_id] = site.id
65 session[:site_id] = site.id
68 redirect_to :controller => 'site', :action => 'index'
66 redirect_to :controller => 'site', :action => 'index'
69 else
67 else
70 - flash[:notice] = 'Wrong site password'
68 + flash[:alert] = 'Wrong site password'
71 redirect_to :controller => 'site', :action => 'login'
69 redirect_to :controller => 'site', :action => 'login'
72 end
70 end
73 end
71 end
74
72
75 def logout
73 def logout
76 redirect_to root_path
74 redirect_to root_path
@@ -15,15 +15,14
15
15
16 before_action :authenticate_by_ip_address, :only => [:list]
16 before_action :authenticate_by_ip_address, :only => [:list]
17
17
18 #reset login, clear session
18 #reset login, clear session
19 #front page
19 #front page
20 def login
20 def login
21 - saved_notice = flash[:notice]
21 + #saved_notice = flash[:notice]
22 - reset_session
22 + #flash[:notice] = saved_notice
23 - flash.now[:notice] = saved_notice
24 @remote_ip = request.remote_ip
23 @remote_ip = request.remote_ip
25
24
26 # EXPERIMENT:
25 # EXPERIMENT:
27 # Hide login if in single user mode and the url does not
26 # Hide login if in single user mode and the url does not
28 # explicitly specify /login
27 # explicitly specify /login
29 #
28 #
@@ -1,11 +1,11
1 class SubmissionsController < ApplicationController
1 class SubmissionsController < ApplicationController
2 before_action :set_submission, only: [:show,:download,:compiler_msg,:rejudge,:set_tag, :edit]
2 before_action :set_submission, only: [:show,:download,:compiler_msg,:rejudge,:set_tag, :edit]
3 before_action :check_valid_login
3 before_action :check_valid_login
4 before_action :submission_authorization, only: [:show, :download, :edit]
4 before_action :submission_authorization, only: [:show, :download, :edit]
5 - before_action only: [:rejudge, :set_tag] do role_authorization([:ta]) end
5 + before_action only: [:rejudge, :set_tag] do authorization_by_roles([:ta]) end
6
6
7 # GET /submissions
7 # GET /submissions
8 # GET /submissions.json
8 # GET /submissions.json
9 # Show problem selection and user's submission of that problem
9 # Show problem selection and user's submission of that problem
10 def index
10 def index
11 @user = @current_user
11 @user = @current_user
@@ -22,13 +22,13
22
22
23 # POST /tags
23 # POST /tags
24 def create
24 def create
25 @tag = Tag.new(tag_params)
25 @tag = Tag.new(tag_params)
26
26
27 if @tag.save
27 if @tag.save
28 - redirect_to @tag, notice: 'Tag was successfully created.'
28 + redirect_to tags_path, notice: 'Tag was successfully created.'
29 else
29 else
30 render :new
30 render :new
31 end
31 end
32 end
32 end
33
33
34 # PATCH/PUT /tags/1
34 # PATCH/PUT /tags/1
@@ -13,11 +13,11
13 - @groups.each do |group|
13 - @groups.each do |group|
14 %tr{:class => "#{(group.enabled?) ? "success" : "danger"}", id: "group-#{group.id}"}
14 %tr{:class => "#{(group.enabled?) ? "success" : "danger"}", id: "group-#{group.id}"}
15 %td= group.name
15 %td= group.name
16 %td= group.description
16 %td= group.description
17 %td= toggle_button(group.enabled?, toggle_group_path(group), "group-enabled-#{group.id}", block: ' ')
17 %td= toggle_button(group.enabled?, toggle_group_path(group), "group-enabled-#{group.id}", block: ' ')
18 %td
18 %td
19 - = link_to 'Edit members and problems', group, class: 'btn btn-secondary btn-sm'
19 + = link_to 'Edit members and problems', group, class: 'btn btn-info btn-sm'
20 = link_to 'Destroy', group, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger btn-sm'
20 = link_to 'Destroy', group, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger btn-sm'
21
21
22 %br
22 %br
23
23
@@ -79,13 +79,13
79 %span.mi.mi-bs.md-18 chat
79 %span.mi.mi-bs.md-18 chat
80 - if GraderConfiguration['system.user_setting_enabled']
80 - if GraderConfiguration['system.user_setting_enabled']
81 %li.nav-item
81 %li.nav-item
82 %a.nav-link{href: profile_users_path}
82 %a.nav-link{href: profile_users_path}
83 %span.mi.mi-bs.md-18 settings
83 %span.mi.mi-bs.md-18 settings
84 %li.nav-item
84 %li.nav-item
85 - %a.nav-link{href: login_main_path}
85 + %a.nav-link{href: logout_main_path}
86 %span.mi.mi-bs.md-18 exit_to_app
86 %span.mi.mi-bs.md-18 exit_to_app
87 = @current_user.full_name
87 = @current_user.full_name
88 :javascript
88 :javascript
89 $('.active-with-children').each( (index,obj) => {
89 $('.active-with-children').each( (index,obj) => {
90 if ($(obj).siblings('.dropdown-menu').has('.active').length > 0) {
90 if ($(obj).siblings('.dropdown-menu').has('.active').length > 0) {
91 $(obj).addClass('active')
91 $(obj).addClass('active')
@@ -4,15 +4,14
4 .card-title
4 .card-title
5 %h3= GraderConfiguration['ui.front.welcome_message']
5 %h3= GraderConfiguration['ui.front.welcome_message']
6 - if !@hidelogin
6 - if !@hidelogin
7 .card-subtitle=t 'login.message'
7 .card-subtitle=t 'login.message'
8
8
9 - if flash[:notice]
9 - if flash[:notice]
10 - %hr/
10 + .alert.alert-danger
11 - %b= flash[:notice]
11 + = flash[:notice]
12 - %hr/
13
12
14 .card
13 .card
15 .card-body{ style: "background: #eeeeff;"}
14 .card-body{ style: "background: #eeeeff;"}
16 = form_with url: login_login_path do |f|
15 = form_with url: login_login_path do |f|
17 .mb-3
16 .mb-3
18 = f.label :login, "Login", class: 'form-label'
17 = f.label :login, "Login", class: 'form-label'
@@ -1,22 +1,7
1 - = form_for @tag do |f|
1 + = simple_form_for @tag do |f|
2 - - if @tag.errors.any?
3 - #error_explanation
4 - %h2= "#{pluralize(@tag.errors.count, "error")} prohibited this tag from being saved:"
5 - %ul
6 - - @tag.errors.full_messages.each do |msg|
7 - %li= msg
8 -
9 .row
2 .row
10 .col-md-6
3 .col-md-6
11 - .form-group.field
4 + = f.input :name
12 - = f.label :name
5 + = f.input :description
13 - = f.text_field :name, class: 'form-control'
6 + = f.input :public
14 - .form-group.field
7 + = f.submit 'Save', class: 'btn btn-primary'
15 - = f.label :description
16 - = f.text_area :description, class: 'form-control'
17 - .form-group.field
18 - = f.label :public
19 - = f.text_field :public, class: 'form-control'
20 - .actions
21 - = f.submit 'Save', class: 'btn btn-primary'
22 - .col-md-6
@@ -15,12 +15,12
15 %tbody
15 %tbody
16 - @tags.each do |tag|
16 - @tags.each do |tag|
17 %tr
17 %tr
18 %td= tag.name
18 %td= tag.name
19 %td= tag.description
19 %td= tag.description
20 %td= tag.public
20 %td= tag.public
21 - %td= link_to 'Show', tag
21 + %td= link_to 'Show', tag, class: 'btn btn-info'
22 - %td= link_to 'Edit', edit_tag_path(tag)
22 + %td= link_to 'Edit', edit_tag_path(tag), class: 'btn btn-info'
23 - %td= link_to 'Destroy', tag, :method => :delete, :data => { :confirm => 'Are you sure?' }
23 + %td= button_to 'Destroy', tag, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger'
24
24
25 %br
25 %br
26
26
@@ -73,14 +73,14
73 %td= user.email
73 %td= user.email
74 %td= user.remark
74 %td= user.remark
75 %td= toggle_button(user.activated?, toggle_activate_user_path(user),"toggle_activate_user_#{user.id}")
75 %td= toggle_button(user.activated?, toggle_activate_user_path(user),"toggle_activate_user_#{user.id}")
76 %td= toggle_button(user.enabled?, toggle_enable_user_path(user),"toggle_enable_user_#{user.id}")
76 %td= toggle_button(user.enabled?, toggle_enable_user_path(user),"toggle_enable_user_#{user.id}")
77 %td= user.last_ip
77 %td= user.last_ip
78 %td= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?', class: 'btn btn-secondary btn-sm btn-block'
78 %td= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?', class: 'btn btn-secondary btn-sm btn-block'
79 - %td= link_to 'Show', {:action => 'show', :id => user}, class: 'btn btn-secondary btn-sm btn-block'
79 + %td= link_to 'Show', {:action => 'show', :id => user}, class: 'btn btn-info btn-sm btn-block'
80 - %td= link_to 'Edit', {:action => 'edit', :id => user}, class: 'btn btn-secondary btn-sm btn-block'
80 + %td= link_to 'Edit', {:action => 'edit', :id => user}, class: 'btn btn-info btn-sm btn-block'
81 %td= link_to 'Destroy', {action: :destroy, id: user}, data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger btn-sm btn-block'
81 %td= link_to 'Destroy', {action: :destroy, id: user}, data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger btn-sm btn-block'
82 %br/
82 %br/
83 = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '}
83 = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '}
84 = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '}
84 = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '}
85
85
86 :javascript
86 :javascript
@@ -8,94 +8,94
8 # migrations from scratch. Old migrations may fail to apply correctly if those
8 # migrations from scratch. Old migrations may fail to apply correctly if those
9 # migrations use external dependencies or application code.
9 # migrations use external dependencies or application code.
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[7.0].define(version: 2022_09_27_074644) do
13 ActiveRecord::Schema[7.0].define(version: 2022_09_27_074644) do
14 - create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
14 + create_table "active_storage_attachments", charset: "latin1", force: :cascade do |t|
15 t.string "name", null: false
15 t.string "name", null: false
16 t.string "record_type", null: false
16 t.string "record_type", null: false
17 t.bigint "record_id", null: false
17 t.bigint "record_id", null: false
18 t.bigint "blob_id", null: false
18 t.bigint "blob_id", null: false
19 t.datetime "created_at", null: false
19 t.datetime "created_at", null: false
20 t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
20 t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
21 t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
21 t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
22 end
22 end
23
23
24 - create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
24 + create_table "active_storage_blobs", charset: "latin1", force: :cascade do |t|
25 t.string "key", null: false
25 t.string "key", null: false
26 t.string "filename", null: false
26 t.string "filename", null: false
27 t.string "content_type"
27 t.string "content_type"
28 t.text "metadata"
28 t.text "metadata"
29 t.string "service_name", null: false
29 t.string "service_name", null: false
30 t.bigint "byte_size", null: false
30 t.bigint "byte_size", null: false
31 t.string "checksum"
31 t.string "checksum"
32 t.datetime "created_at", null: false
32 t.datetime "created_at", null: false
33 t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
33 t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
34 end
34 end
35
35
36 - create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
36 + create_table "active_storage_variant_records", charset: "latin1", force: :cascade do |t|
37 t.bigint "blob_id", null: false
37 t.bigint "blob_id", null: false
38 t.string "variation_digest", null: false
38 t.string "variation_digest", null: false
39 t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
39 t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
40 end
40 end
41
41
42 - create_table "announcements", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
42 + create_table "announcements", id: :integer, charset: "utf8", force: :cascade do |t|
43 t.string "author"
43 t.string "author"
44 - t.text "body"
44 + t.text "body", size: :medium
45 t.boolean "published"
45 t.boolean "published"
46 t.datetime "created_at", precision: nil, null: false
46 t.datetime "created_at", precision: nil, null: false
47 t.datetime "updated_at", precision: nil, null: false
47 t.datetime "updated_at", precision: nil, null: false
48 t.boolean "frontpage", default: false
48 t.boolean "frontpage", default: false
49 t.boolean "contest_only", default: false
49 t.boolean "contest_only", default: false
50 t.string "title"
50 t.string "title"
51 t.string "notes"
51 t.string "notes"
52 t.boolean "on_nav_bar", default: false
52 t.boolean "on_nav_bar", default: false
53 end
53 end
54
54
55 - create_table "contests", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
55 + create_table "contests", id: :integer, charset: "utf8", force: :cascade do |t|
56 t.string "title"
56 t.string "title"
57 t.boolean "enabled"
57 t.boolean "enabled"
58 t.datetime "created_at", precision: nil, null: false
58 t.datetime "created_at", precision: nil, null: false
59 t.datetime "updated_at", precision: nil, null: false
59 t.datetime "updated_at", precision: nil, null: false
60 t.string "name"
60 t.string "name"
61 end
61 end
62
62
63 - create_table "contests_problems", id: false, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
63 + create_table "contests_problems", id: false, charset: "utf8", force: :cascade do |t|
64 t.integer "contest_id"
64 t.integer "contest_id"
65 t.integer "problem_id"
65 t.integer "problem_id"
66 end
66 end
67
67
68 - create_table "contests_users", id: false, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
68 + create_table "contests_users", id: false, charset: "utf8", force: :cascade do |t|
69 t.integer "contest_id"
69 t.integer "contest_id"
70 t.integer "user_id"
70 t.integer "user_id"
71 end
71 end
72
72
73 - create_table "countries", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
73 + create_table "countries", id: :integer, charset: "utf8", force: :cascade do |t|
74 t.string "name"
74 t.string "name"
75 t.datetime "created_at", precision: nil, null: false
75 t.datetime "created_at", precision: nil, null: false
76 t.datetime "updated_at", precision: nil, null: false
76 t.datetime "updated_at", precision: nil, null: false
77 end
77 end
78
78
79 - create_table "descriptions", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
79 + create_table "descriptions", id: :integer, charset: "utf8", force: :cascade do |t|
80 - t.text "body"
80 + t.text "body", size: :medium
81 t.boolean "markdowned"
81 t.boolean "markdowned"
82 t.datetime "created_at", precision: nil, null: false
82 t.datetime "created_at", precision: nil, null: false
83 t.datetime "updated_at", precision: nil, null: false
83 t.datetime "updated_at", precision: nil, null: false
84 end
84 end
85
85
86 - create_table "grader_configurations", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
86 + create_table "grader_configurations", id: :integer, charset: "utf8", force: :cascade do |t|
87 t.string "key"
87 t.string "key"
88 t.string "value_type"
88 t.string "value_type"
89 t.string "value"
89 t.string "value"
90 t.datetime "created_at", precision: nil, null: false
90 t.datetime "created_at", precision: nil, null: false
91 t.datetime "updated_at", precision: nil, null: false
91 t.datetime "updated_at", precision: nil, null: false
92 - t.text "description"
92 + t.text "description", size: :medium
93 end
93 end
94
94
95 - create_table "grader_processes", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
95 + create_table "grader_processes", id: :integer, charset: "utf8", force: :cascade do |t|
96 t.string "host"
96 t.string "host"
97 t.integer "pid"
97 t.integer "pid"
98 t.string "mode"
98 t.string "mode"
99 t.boolean "active"
99 t.boolean "active"
100 t.datetime "created_at", precision: nil, null: false
100 t.datetime "created_at", precision: nil, null: false
101 t.datetime "updated_at", precision: nil, null: false
101 t.datetime "updated_at", precision: nil, null: false
@@ -120,48 +120,48
120 create_table "groups_users", charset: "latin1", force: :cascade do |t|
120 create_table "groups_users", charset: "latin1", force: :cascade do |t|
121 t.integer "group_id", null: false
121 t.integer "group_id", null: false
122 t.integer "user_id", null: false
122 t.integer "user_id", null: false
123 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
123 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
124 end
124 end
125
125
126 - create_table "heart_beats", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
126 + create_table "heart_beats", id: :integer, charset: "latin1", force: :cascade do |t|
127 t.integer "user_id"
127 t.integer "user_id"
128 t.string "ip_address"
128 t.string "ip_address"
129 t.datetime "created_at", precision: nil, null: false
129 t.datetime "created_at", precision: nil, null: false
130 t.datetime "updated_at", precision: nil, null: false
130 t.datetime "updated_at", precision: nil, null: false
131 t.string "status"
131 t.string "status"
132 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
132 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
133 end
133 end
134
134
135 - create_table "languages", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
135 + create_table "languages", id: :integer, charset: "utf8", force: :cascade do |t|
136 t.string "name", limit: 10
136 t.string "name", limit: 10
137 t.string "pretty_name"
137 t.string "pretty_name"
138 t.string "ext", limit: 10
138 t.string "ext", limit: 10
139 t.string "common_ext"
139 t.string "common_ext"
140 end
140 end
141
141
142 - create_table "logins", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
142 + create_table "logins", id: :integer, charset: "latin1", force: :cascade do |t|
143 t.integer "user_id"
143 t.integer "user_id"
144 t.string "ip_address"
144 t.string "ip_address"
145 t.datetime "created_at", precision: nil, null: false
145 t.datetime "created_at", precision: nil, null: false
146 t.datetime "updated_at", precision: nil, null: false
146 t.datetime "updated_at", precision: nil, null: false
147 t.index ["user_id"], name: "index_logins_on_user_id"
147 t.index ["user_id"], name: "index_logins_on_user_id"
148 end
148 end
149
149
150 - create_table "messages", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
150 + create_table "messages", id: :integer, charset: "utf8", force: :cascade do |t|
151 t.integer "sender_id"
151 t.integer "sender_id"
152 t.integer "receiver_id"
152 t.integer "receiver_id"
153 t.integer "replying_message_id"
153 t.integer "replying_message_id"
154 - t.text "body"
154 + t.text "body", size: :medium
155 t.boolean "replied"
155 t.boolean "replied"
156 t.datetime "created_at", precision: nil, null: false
156 t.datetime "created_at", precision: nil, null: false
157 t.datetime "updated_at", precision: nil, null: false
157 t.datetime "updated_at", precision: nil, null: false
158 end
158 end
159
159
160 - create_table "problems", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
160 + create_table "problems", id: :bigint, default: nil, charset: "utf8", force: :cascade do |t|
161 - t.string "name", limit: 30
161 + t.string "name", limit: 100
162 t.string "full_name"
162 t.string "full_name"
163 t.integer "full_score"
163 t.integer "full_score"
164 t.date "date_added"
164 t.date "date_added"
165 t.boolean "available"
165 t.boolean "available"
166 t.string "url"
166 t.string "url"
167 t.integer "description_id"
167 t.integer "description_id"
@@ -171,79 +171,88
171 t.boolean "view_testcase"
171 t.boolean "view_testcase"
172 t.integer "difficulty"
172 t.integer "difficulty"
173 t.text "description"
173 t.text "description"
174 t.boolean "markdown"
174 t.boolean "markdown"
175 end
175 end
176
176
177 - create_table "problems_tags", id: :integer, charset: "latin1", force: :cascade do |t|
177 + create_table "problems_tags", id: :bigint, default: nil, charset: "latin1", force: :cascade do |t|
178 - t.integer "problem_id"
178 + t.bigint "problem_id"
179 t.integer "tag_id"
179 t.integer "tag_id"
180 t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true
180 t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true
181 t.index ["problem_id"], name: "index_problems_tags_on_problem_id"
181 t.index ["problem_id"], name: "index_problems_tags_on_problem_id"
182 t.index ["tag_id"], name: "index_problems_tags_on_tag_id"
182 t.index ["tag_id"], name: "index_problems_tags_on_tag_id"
183 end
183 end
184
184
185 - create_table "rights", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
185 + create_table "rights", id: :integer, charset: "utf8", force: :cascade do |t|
186 t.string "name"
186 t.string "name"
187 t.string "controller"
187 t.string "controller"
188 t.string "action"
188 t.string "action"
189 end
189 end
190
190
191 - create_table "rights_roles", id: false, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
191 + create_table "rights_roles", id: false, charset: "utf8", force: :cascade do |t|
192 t.integer "right_id"
192 t.integer "right_id"
193 t.integer "role_id"
193 t.integer "role_id"
194 t.index ["role_id"], name: "index_rights_roles_on_role_id"
194 t.index ["role_id"], name: "index_rights_roles_on_role_id"
195 end
195 end
196
196
197 - create_table "roles", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
197 + create_table "roles", id: :integer, charset: "utf8", force: :cascade do |t|
198 t.string "name"
198 t.string "name"
199 end
199 end
200
200
201 - create_table "roles_users", id: false, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
201 + create_table "roles_users", id: false, charset: "utf8", force: :cascade do |t|
202 t.integer "role_id"
202 t.integer "role_id"
203 t.integer "user_id"
203 t.integer "user_id"
204 t.index ["user_id"], name: "index_roles_users_on_user_id"
204 t.index ["user_id"], name: "index_roles_users_on_user_id"
205 end
205 end
206
206
207 - create_table "sessions", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
207 + create_table "sessions", id: :integer, charset: "utf8", force: :cascade do |t|
208 t.string "session_id"
208 t.string "session_id"
209 - t.text "data"
209 + t.text "data", size: :medium
210 t.datetime "updated_at", precision: nil
210 t.datetime "updated_at", precision: nil
211 t.index ["session_id"], name: "index_sessions_on_session_id"
211 t.index ["session_id"], name: "index_sessions_on_session_id"
212 t.index ["updated_at"], name: "index_sessions_on_updated_at"
212 t.index ["updated_at"], name: "index_sessions_on_updated_at"
213 end
213 end
214
214
215 - create_table "sites", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
215 + create_table "sites", id: :integer, charset: "utf8", force: :cascade do |t|
216 t.string "name"
216 t.string "name"
217 t.boolean "started"
217 t.boolean "started"
218 t.datetime "start_time", precision: nil
218 t.datetime "start_time", precision: nil
219 t.datetime "created_at", precision: nil, null: false
219 t.datetime "created_at", precision: nil, null: false
220 t.datetime "updated_at", precision: nil, null: false
220 t.datetime "updated_at", precision: nil, null: false
221 t.integer "country_id"
221 t.integer "country_id"
222 t.string "password"
222 t.string "password"
223 end
223 end
224
224
225 - create_table "submission_view_logs", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
225 + create_table "solutions", charset: "latin1", force: :cascade do |t|
226 + t.string "solution"
227 + t.bigint "problem_id"
228 + t.bigint "submission_id"
229 + t.integer "type"
230 + t.index ["problem_id"], name: "index_solutions_on_problem_id"
231 + t.index ["submission_id"], name: "index_solutions_on_submission_id"
232 + end
233 +
234 + create_table "submission_view_logs", id: :integer, charset: "latin1", force: :cascade do |t|
226 t.integer "user_id"
235 t.integer "user_id"
227 t.integer "submission_id"
236 t.integer "submission_id"
228 t.datetime "created_at", precision: nil, null: false
237 t.datetime "created_at", precision: nil, null: false
229 t.datetime "updated_at", precision: nil, null: false
238 t.datetime "updated_at", precision: nil, null: false
230 end
239 end
231
240
232 - create_table "submissions", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
241 + create_table "submissions", id: :bigint, default: nil, charset: "utf8", force: :cascade do |t|
233 t.integer "user_id"
242 t.integer "user_id"
234 t.integer "problem_id"
243 t.integer "problem_id"
235 t.integer "language_id"
244 t.integer "language_id"
236 t.text "source", size: :medium
245 t.text "source", size: :medium
237 t.binary "binary"
246 t.binary "binary"
238 t.datetime "submitted_at", precision: nil
247 t.datetime "submitted_at", precision: nil
239 t.datetime "compiled_at", precision: nil
248 t.datetime "compiled_at", precision: nil
240 - t.text "compiler_message"
249 + t.text "compiler_message", size: :medium
241 t.datetime "graded_at", precision: nil
250 t.datetime "graded_at", precision: nil
242 t.integer "points"
251 t.integer "points"
243 - t.text "grader_comment"
252 + t.text "grader_comment", size: :medium
244 t.integer "number"
253 t.integer "number"
245 t.string "source_filename"
254 t.string "source_filename"
246 t.float "max_runtime"
255 t.float "max_runtime"
247 t.integer "peak_memory"
256 t.integer "peak_memory"
248 t.integer "effective_code_length"
257 t.integer "effective_code_length"
249 t.string "ip_address"
258 t.string "ip_address"
@@ -258,41 +267,41
258 t.text "description"
267 t.text "description"
259 t.boolean "public"
268 t.boolean "public"
260 t.datetime "created_at", precision: nil, null: false
269 t.datetime "created_at", precision: nil, null: false
261 t.datetime "updated_at", precision: nil, null: false
270 t.datetime "updated_at", precision: nil, null: false
262 end
271 end
263
272
264 - create_table "tasks", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
273 + create_table "tasks", id: :integer, charset: "utf8", force: :cascade do |t|
265 t.integer "submission_id"
274 t.integer "submission_id"
266 t.datetime "created_at", precision: nil
275 t.datetime "created_at", precision: nil
267 t.integer "status"
276 t.integer "status"
268 t.datetime "updated_at", precision: nil
277 t.datetime "updated_at", precision: nil
269 t.index ["status"], name: "index_tasks_on_status"
278 t.index ["status"], name: "index_tasks_on_status"
270 t.index ["submission_id"], name: "index_tasks_on_submission_id"
279 t.index ["submission_id"], name: "index_tasks_on_submission_id"
271 end
280 end
272
281
273 - create_table "test_pairs", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
282 + create_table "test_pairs", id: :integer, charset: "utf8", force: :cascade do |t|
274 t.integer "problem_id"
283 t.integer "problem_id"
275 - t.text "input", size: :medium
284 + t.text "input", size: :long
276 - t.text "solution", size: :medium
285 + t.text "solution", size: :long
277 t.datetime "created_at", precision: nil, null: false
286 t.datetime "created_at", precision: nil, null: false
278 t.datetime "updated_at", precision: nil, null: false
287 t.datetime "updated_at", precision: nil, null: false
279 end
288 end
280
289
281 - create_table "test_requests", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
290 + create_table "test_requests", id: :integer, charset: "utf8", force: :cascade do |t|
282 t.integer "user_id"
291 t.integer "user_id"
283 t.integer "problem_id"
292 t.integer "problem_id"
284 t.integer "submission_id"
293 t.integer "submission_id"
285 t.string "input_file_name"
294 t.string "input_file_name"
286 t.string "output_file_name"
295 t.string "output_file_name"
287 t.string "running_stat"
296 t.string "running_stat"
288 t.integer "status"
297 t.integer "status"
289 t.datetime "updated_at", precision: nil, null: false
298 t.datetime "updated_at", precision: nil, null: false
290 t.datetime "submitted_at", precision: nil
299 t.datetime "submitted_at", precision: nil
291 t.datetime "compiled_at", precision: nil
300 t.datetime "compiled_at", precision: nil
292 - t.text "compiler_message"
301 + t.text "compiler_message", size: :medium
293 t.datetime "graded_at", precision: nil
302 t.datetime "graded_at", precision: nil
294 t.string "grader_comment"
303 t.string "grader_comment"
295 t.datetime "created_at", precision: nil, null: false
304 t.datetime "created_at", precision: nil, null: false
296 t.float "running_time"
305 t.float "running_time"
297 t.string "exit_status"
306 t.string "exit_status"
298 t.integer "memory_usage"
307 t.integer "memory_usage"
@@ -303,44 +312,46
303 t.integer "problem_id"
312 t.integer "problem_id"
304 t.integer "num"
313 t.integer "num"
305 t.integer "group"
314 t.integer "group"
306 t.integer "score"
315 t.integer "score"
307 t.text "input", size: :long
316 t.text "input", size: :long
308 t.text "sol", size: :long
317 t.text "sol", size: :long
309 - t.datetime "created_at", precision: nil
318 + t.datetime "created_at", precision: nil, null: false
310 - t.datetime "updated_at", precision: nil
319 + t.datetime "updated_at", precision: nil, null: false
311 t.index ["problem_id"], name: "index_testcases_on_problem_id"
320 t.index ["problem_id"], name: "index_testcases_on_problem_id"
312 end
321 end
313
322
314 - create_table "user_contest_stats", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
323 + create_table "user_contest_stats", id: :integer, charset: "utf8", force: :cascade do |t|
315 t.integer "user_id"
324 t.integer "user_id"
316 t.datetime "started_at", precision: nil
325 t.datetime "started_at", precision: nil
317 t.datetime "created_at", precision: nil, null: false
326 t.datetime "created_at", precision: nil, null: false
318 t.datetime "updated_at", precision: nil, null: false
327 t.datetime "updated_at", precision: nil, null: false
319 t.boolean "forced_logout"
328 t.boolean "forced_logout"
320 end
329 end
321
330
322 - create_table "users", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
331 + create_table "users", id: :integer, charset: "utf8", force: :cascade do |t|
323 t.string "login", limit: 50
332 t.string "login", limit: 50
324 t.string "full_name"
333 t.string "full_name"
325 t.string "hashed_password"
334 t.string "hashed_password"
326 t.string "salt", limit: 5
335 t.string "salt", limit: 5
327 t.string "alias"
336 t.string "alias"
328 t.string "email"
337 t.string "email"
329 t.integer "site_id"
338 t.integer "site_id"
330 t.integer "country_id"
339 t.integer "country_id"
331 t.boolean "activated", default: false
340 t.boolean "activated", default: false
332 t.datetime "created_at", precision: nil
341 t.datetime "created_at", precision: nil
333 t.datetime "updated_at", precision: nil
342 t.datetime "updated_at", precision: nil
343 + t.string "section"
334 t.boolean "enabled", default: true
344 t.boolean "enabled", default: true
335 t.string "remark"
345 t.string "remark"
336 t.string "last_ip"
346 t.string "last_ip"
337 - t.string "section"
338 t.integer "default_language"
347 t.integer "default_language"
339 t.index ["login"], name: "index_users_on_login", unique: true
348 t.index ["login"], name: "index_users_on_login", unique: true
340 end
349 end
341
350
342 add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
351 add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
343 add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
352 add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
344 add_foreign_key "problems_tags", "problems"
353 add_foreign_key "problems_tags", "problems"
345 add_foreign_key "problems_tags", "tags"
354 add_foreign_key "problems_tags", "tags"
355 + add_foreign_key "solutions", "problems"
356 + add_foreign_key "solutions", "submissions"
346 end
357 end
You need to be logged in to leave comments. Login now