diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -152,8 +152,9 @@
def is_request_ip_allowed?
unless GraderConfiguration[WHITELIST_IGNORE_CONF_KEY]
user_ip = IPAddr.new(request.remote_ip)
+ allowed = GraderConfiguration[WHITELIST_IP_CONF_KEY] || ''
- GraderConfiguration[WHITELIST_IP_CONF_KEY].delete(' ').split(',').each do |ips|
+ allowed.delete(' ').split(',').each do |ips|
allow_ips = IPAddr.new(ips)
if allow_ips.include?(user_ip)
return true
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -2,6 +2,7 @@
before_action :set_group, only: [:show, :edit, :update, :destroy,
:add_user, :remove_user,:remove_all_user,
:add_problem, :remove_problem,:remove_all_problem,
+ :toggle,
]
before_action :admin_authorization
@@ -49,6 +50,11 @@
redirect_to groups_url, notice: 'Group was successfully destroyed.'
end
+ def toggle
+ @group.enabled = @group.enabled? ? false : true
+ @group.save
+ end
+
def remove_user
user = User.find(params[:user_id])
@group.users.delete(user)
@@ -99,6 +105,6 @@
# Only allow a trusted parameter "white list" through.
def group_params
- params.require(:group).permit(:name, :description)
+ params.require(:group).permit(:name, :description, :enabled)
end
end
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -188,7 +188,7 @@
@user = user
end
end
-
+
protected
def prepare_announcements(recent=nil)
diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb
--- a/app/controllers/submissions_controller.rb
+++ b/app/controllers/submissions_controller.rb
@@ -16,8 +16,8 @@
else
@problem = Problem.find_by_id(params[:problem_id])
if (@problem == nil) or (not @problem.available)
- redirect_to main_list_path
- flash[:notice] = 'Error: submissions for that problem are not viewable.'
+ redirect_to list_main_path
+ flash[:error] = 'Authorization error: You have no right to view submissions for this problem'
return
end
@submissions = Submission.find_all_by_user_problem(@user.id, @problem.id).order(id: :desc)
diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb
--- a/app/controllers/tasks_controller.rb
+++ b/app/controllers/tasks_controller.rb
@@ -27,8 +27,9 @@
def download
problem = Problem.find(params[:id])
unless @current_user.can_view_problem? problem
- flash[:notice] = 'You are not authorized to access this file'
- redirect_to :action => 'index' and return
+ flash[:error] = 'You are not authorized to access this file'
+ redirect_to list_main_path
+ return
end
base_name = params[:file]
@@ -37,7 +38,8 @@
if !FileTest.exists?(filename)
flash[:notice] = 'File does not exists'
- redirect_to :action => 'index' and return
+ redirect_to list_main_path
+ return
end
send_file_to_user(filename, base_filename)
diff --git a/app/controllers/user_admin_controller.rb b/app/controllers/user_admin_controller.rb
--- a/app/controllers/user_admin_controller.rb
+++ b/app/controllers/user_admin_controller.rb
@@ -65,7 +65,8 @@
ok_user = []
lines.split("\n").each do |line|
- items = line.chomp.split(',')
+ #split with large limit, this will cause consecutive ',' to be result in a blank
+ items = line.chomp.split(',',1000)
if items.length>=2
login = items[0]
full_name = items[1]
@@ -73,8 +74,12 @@
user_alias = ''
added_random_password = false
- if items.length >= 3 and items[2].chomp(" ").length > 0;
- password = items[2].chomp(" ")
+ added_password = false
+ if items.length >= 3
+ if items[2].chomp(" ").length > 0
+ password = items[2].chomp(" ")
+ added_password = true
+ end
else
password = random_password
added_random_password=true;
@@ -86,16 +91,21 @@
user_alias = login
end
+
+ has_remark = false
if items.length>=5
remark = items[4].strip;
+ has_remark = true
end
user = User.find_by_login(login)
if (user)
user.full_name = full_name
- user.password = password
- user.remark = remark
+ user.remark = remark if has_remark
+ user.password = password if added_password || added_random_password
else
+ #create a random password if none are given
+ password = random_password unless password
user = User.new({:login => login,
:full_name => full_name,
:password => password,
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -113,8 +113,9 @@
def toggle_button(on,toggle_url,id, option={})
btn_size = option[:size] || 'btn-xs'
+ btn_block = option[:block] || 'btn-block'
link_to (on ? "Yes" : "No"), toggle_url,
- {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle",
+ {class: "btn #{btn_block} #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle",
id: id,
data: {remote: true, method: 'get'}}
end
@@ -181,9 +182,6 @@
#{header}
-#{user.full_name}
-#{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)}
-#{time_left}
|
#{contest_name} |
diff --git a/app/helpers/main_helper.rb b/app/helpers/main_helper.rb
--- a/app/helpers/main_helper.rb
+++ b/app/helpers/main_helper.rb
@@ -1,17 +1,11 @@
module MainHelper
- def link_to_description_if_any(name, problem, options={})
+ def link_to_description_if_any(name, problem)
if !problem.url.blank?
- return link_to name, problem.url, options
+ return link_to name, problem.url
elsif !problem.description_filename.blank?
- #build a link to a problem (via task controller)
basename, ext = problem.description_filename.split('.')
- options[:controller] = 'tasks'
- options[:action] = 'download'
- options[:id] = problem.id
- options[:file] = basename
- options[:ext] = ext
- return link_to name, options
+ return link_to name, download_task_path(problem.id,basename,ext), target: '_blank'
else
return ''
end
diff --git a/app/models/submission.rb b/app/models/submission.rb
--- a/app/models/submission.rb
+++ b/app/models/submission.rb
@@ -154,7 +154,7 @@
return if self.user.admin?
#check if user has the right to submit the problem
- errors.add('problem',"must be valid.") if (!self.user.available_problems.include?(self.problem)) and (self.new_record?)
+ 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?)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -316,9 +316,10 @@
end
end
+ # new feature, get list of available problem in all enabled group that the user belongs to
def available_problems_in_group
problem = []
- self.groups.each do |group|
+ self.groups.where(enabled: true).each do |group|
group.problems.where(available: true).each { |p| problem << p }
end
problem.uniq!
@@ -339,6 +340,8 @@
end
end
+ #check if the user has the right to view that problem
+ #this also consider group based problem policy
def can_view_problem?(problem)
return true if admin?
return available_problems.include? problem
diff --git a/app/views/application/_submission.html.haml b/app/views/application/_submission.html.haml
--- a/app/views/application/_submission.html.haml
+++ b/app/views/application/_submission.html.haml
@@ -10,7 +10,7 @@
%td
= submission.source_filename
= " (#{submission.language.pretty_name}) "
- = link_to('[load]',{:action => 'source', :id => submission.id})
+ = link_to '[load]', download_submission_path(submission)
%td
- if submission.graded_at
= "Graded at #{format_short_time(submission.graded_at)}."
diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml
--- a/app/views/groups/_form.html.haml
+++ b/app/views/groups/_form.html.haml
@@ -5,12 +5,23 @@
%ul
- @group.errors.full_messages.each do |msg|
%li= msg
-
- .form-group.field
- = f.label :name
- = f.text_field :name, class: 'form-control'
- .form-group.field
- = f.label :description
- = f.text_field :description, class: 'form-control'
- .form-group.actions
- = f.submit 'Save', class: 'btn btn-primary'
+ .row
+ .col-md-6
+ .form-group.field
+ = f.label :name
+ = f.text_field :name, class: 'form-control'
+ .row
+ .col-md-6
+ .form-group.field
+ = f.label :description
+ = f.text_field :description, class: 'form-control'
+ .row
+ .col-md-6
+ .checkbox
+ = f.label :enabled do
+ = f.check_box :enabled
+ Enabled
+ .row
+ .col-md-6
+ .form-group.actions
+ = f.submit 'Save', class: 'btn btn-primary'
diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml
--- a/app/views/groups/index.html.haml
+++ b/app/views/groups/index.html.haml
@@ -7,14 +7,16 @@
%tr
%th Name
%th Description
+ %th Enabled?
%th
%th
%tbody
- @groups.each do |group|
- %tr
+ %tr{:class => "#{(group.enabled?) ? "success" : "danger"}", id: "group-#{group.id}"}
%td= group.name
%td= group.description
+ %td= toggle_button(group.enabled?, toggle_group_path(group), "group-enabled-#{group.id}", size: ' ', block: ' ')
%td= link_to 'View', group, class: 'btn btn-default'
%td= link_to 'Destroy', group, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger'
diff --git a/app/views/groups/toggle.js.haml b/app/views/groups/toggle.js.haml
new file mode 100644
--- /dev/null
+++ b/app/views/groups/toggle.js.haml
@@ -0,0 +1,8 @@
+= render partial: 'toggle_button',
+ locals: {button_id: "#group-enabled-#{@group.id}",button_on: @group.enabled }
+:plain
+ r = $("#group-#{@group.id}");
+ r.removeClass('success');
+ r.removeClass('danger');
+ r.addClass("#{@group.enabled? ? 'success' : 'danger'}");
+
diff --git a/app/views/main/help.html.haml b/app/views/main/help.html.haml
--- a/app/views/main/help.html.haml
+++ b/app/views/main/help.html.haml
@@ -43,5 +43,5 @@
%tt {
LANG: Pascal
TASK: mobiles
}
%p
- = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list')))
+ = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),url: messages_path ))
diff --git a/app/views/submissions/show.html.haml b/app/views/submissions/show.html.haml
--- a/app/views/submissions/show.html.haml
+++ b/app/views/submissions/show.html.haml
@@ -42,6 +42,7 @@
- if @submission.problem!=nil
= link_to "[#{@submission.problem.name}]", stat_problem_path(@submission.problem)
= @submission.problem.full_name
+ = link_to_description_if_any "[download] ".html_safe, @submission.problem
- else
= "(n/a)"
%tr
diff --git a/app/views/user_admin/new_list.html.haml b/app/views/user_admin/new_list.html.haml
--- a/app/views/user_admin/new_list.html.haml
+++ b/app/views/user_admin/new_list.html.haml
@@ -26,6 +26,15 @@
is empty, the original value will be used instead.
%li
If the users with the same user_id already exists, existing information will be overwritten.
+ Example:
+ %ol
+ %li
+ %pre user1,Somchai Jaidee
+ will create (or update) a user with login "user1" and setting the fullname to "Somchai Jaidee", also setting a random password.
+ %li
+ %pre user1,Somchai Jaidee,
+ will create (or update) a user with login "user1" and and setting the fullname "Somchai Jaidee". No change is made to the password unless this is a new user. If this is a new user, a random password will be generated.
+
.row
.col-md-6
diff --git a/config/routes.rb b/config/routes.rb
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -54,6 +54,7 @@
post 'add_problem', to: 'groups#add_problem', as: 'add_problem'
delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem'
delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem'
+ get 'toggle'
end
collection do
@@ -92,7 +93,6 @@
get 'download'
get 'compiler_msg'
get 'rejudge'
- get 'source'
end
collection do
get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
@@ -177,7 +177,7 @@
#
get 'tasks/view/:file.:ext' => 'tasks#view'
- get 'tasks/download/:id/:file.:ext' => 'tasks#download'
+ get 'tasks/download/:id/:file.:ext' => 'tasks#download', as: 'download_task'
get 'heartbeat/:id/edit' => 'heartbeat#edit'
#grader
diff --git a/db/migrate/20200813083020_add_enabled_to_group.rb b/db/migrate/20200813083020_add_enabled_to_group.rb
new file mode 100644
--- /dev/null
+++ b/db/migrate/20200813083020_add_enabled_to_group.rb
@@ -0,0 +1,5 @@
+class AddEnabledToGroup < ActiveRecord::Migration[5.2]
+ def change
+ add_column :groups, :enabled, :boolean, default: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,76 +10,77 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2018_06_12_102327) do
+ActiveRecord::Schema.define(version: 2020_08_13_083020) do
- create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "author"
t.text "body"
t.boolean "published"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "frontpage", default: false
t.boolean "contest_only", default: false
t.string "title"
t.string "notes"
end
- create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "title"
t.boolean "enabled"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "name"
end
- create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "contest_id"
t.integer "problem_id"
end
- create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "contest_id"
t.integer "user_id"
end
- create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.text "body"
t.boolean "markdowned"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "key"
t.string "value_type"
t.string "value"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.text "description"
end
- create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "host"
t.integer "pid"
t.string "mode"
t.boolean "active"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "task_id"
t.string "task_type"
t.boolean "terminated"
- t.index ["host", "pid"], name: "index_grader_processes_on_host_and_pid"
+ t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid"
end
create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
t.string "name"
t.string "description"
+ t.boolean "enabled", default: true
end
create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
@@ -94,40 +95,40 @@
t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
end
- create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.string "ip_address"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "status"
t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
end
- create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name", limit: 10
t.string "pretty_name"
t.string "ext", limit: 10
t.string "common_ext"
end
- create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.string "ip_address"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "sender_id"
t.integer "receiver_id"
t.integer "replying_message_id"
t.text "body"
t.boolean "replied"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name", limit: 30
t.string "full_name"
t.integer "full_score"
@@ -149,29 +150,29 @@
t.index ["tag_id"], name: "index_problems_tags_on_tag_id"
end
- create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name"
t.string "controller"
t.string "action"
end
- create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "right_id"
t.integer "role_id"
t.index ["role_id"], name: "index_rights_roles_on_role_id"
end
- create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name"
end
- create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "role_id"
t.integer "user_id"
t.index ["user_id"], name: "index_roles_users_on_user_id"
end
- create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "session_id"
t.text "data"
t.datetime "updated_at"
@@ -179,24 +180,24 @@
t.index ["updated_at"], name: "index_sessions_on_updated_at"
end
- create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "name"
t.boolean "started"
t.datetime "start_time"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "country_id"
t.string "password"
end
- create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.integer "submission_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.integer "problem_id"
t.integer "language_id"
@@ -226,7 +227,7 @@
t.datetime "updated_at", null: false
end
- create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "submission_id"
t.datetime "created_at"
t.integer "status"
@@ -234,15 +235,15 @@
t.index ["submission_id"], name: "index_tasks_on_submission_id"
end
- create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "problem_id"
t.text "input", limit: 16777215
t.text "solution", limit: 16777215
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.integer "problem_id"
t.integer "submission_id"
@@ -250,13 +251,13 @@
t.string "output_file_name"
t.string "running_stat"
t.integer "status"
- t.datetime "updated_at"
+ t.datetime "updated_at", null: false
t.datetime "submitted_at"
t.datetime "compiled_at"
t.text "compiler_message"
t.datetime "graded_at"
t.string "grader_comment"
- t.datetime "created_at"
+ t.datetime "created_at", null: false
t.float "running_time"
t.string "exit_status"
t.integer "memory_usage"
@@ -275,15 +276,15 @@
t.index ["problem_id"], name: "index_testcases_on_problem_id"
end
- create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.integer "user_id"
t.datetime "started_at"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "forced_logout"
end
- create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
+ create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.string "login", limit: 50
t.string "full_name"
t.string "hashed_password"
@@ -295,10 +296,10 @@
t.boolean "activated", default: false
t.datetime "created_at"
t.datetime "updated_at"
- t.string "section"
t.boolean "enabled", default: true
t.string "remark"
t.string "last_ip"
+ t.string "section"
t.index ["login"], name: "index_users_on_login", unique: true
end