Description:
created join tables for contests and users and problems
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r268:5fffb74cc182 - - 6 files changed: 42 inserted, 1 deleted

@@ -0,0 +1,12
1 + class CreateContestsUsersJoinTable < ActiveRecord::Migration
2 + def self.up
3 + create_table :contests_users, :id => false do |t|
4 + t.integer :contest_id
5 + t.integer :user_id
6 + end
7 + end
8 +
9 + def self.down
10 + drop_table :contests_users
11 + end
12 + end
@@ -0,0 +1,12
1 + class CreateContestsProblemsJoinTable < ActiveRecord::Migration
2 + def self.up
3 + create_table :contests_problems, :id => false do |t|
4 + t.integer :contest_id
5 + t.integer :problem_id
6 + end
7 + end
8 +
9 + def self.down
10 + drop_table :contests_problems
11 + end
12 + end
@@ -1,2 +1,6
1 class Contest < ActiveRecord::Base
1 class Contest < ActiveRecord::Base
2 +
3 + has_and_belongs_to_many :users
4 + has_and_belongs_to_many :problems
5 +
2 end
6 end
@@ -1,101 +1,102
1 class Problem < ActiveRecord::Base
1 class Problem < ActiveRecord::Base
2
2
3 belongs_to :description
3 belongs_to :description
4 + has_and_belongs_to_many :contests
4 has_many :test_pairs, :dependent => :delete_all
5 has_many :test_pairs, :dependent => :delete_all
5
6
6 validates_presence_of :name
7 validates_presence_of :name
7 validates_format_of :name, :with => /^\w+$/
8 validates_format_of :name, :with => /^\w+$/
8 validates_presence_of :full_name
9 validates_presence_of :full_name
9
10
10 DEFAULT_TIME_LIMIT = 1
11 DEFAULT_TIME_LIMIT = 1
11 DEFAULT_MEMORY_LIMIT = 32
12 DEFAULT_MEMORY_LIMIT = 32
12
13
13 def self.find_available_problems
14 def self.find_available_problems
14 find(:all, :conditions => {:available => true}, :order => "date_added DESC")
15 find(:all, :conditions => {:available => true}, :order => "date_added DESC")
15 end
16 end
16
17
17 def self.create_from_import_form_params(params, old_problem=nil)
18 def self.create_from_import_form_params(params, old_problem=nil)
18 problem = old_problem || Problem.new
19 problem = old_problem || Problem.new
19 import_params = Problem.extract_params_and_check(params, problem)
20 import_params = Problem.extract_params_and_check(params, problem)
20
21
21 if not problem.valid?
22 if not problem.valid?
22 return problem, 'Error importing'
23 return problem, 'Error importing'
23 end
24 end
24
25
25 problem.full_score = 100
26 problem.full_score = 100
26 problem.date_added = Time.new
27 problem.date_added = Time.new
27 problem.test_allowed = true
28 problem.test_allowed = true
28 problem.output_only = false
29 problem.output_only = false
29 problem.available = false
30 problem.available = false
30
31
31 if not problem.save
32 if not problem.save
32 return problem, 'Error importing'
33 return problem, 'Error importing'
33 end
34 end
34
35
35 import_to_db = params.has_key? :import_to_db
36 import_to_db = params.has_key? :import_to_db
36
37
37 importer = TestdataImporter.new(problem)
38 importer = TestdataImporter.new(problem)
38
39
39 if not importer.import_from_file(import_params[:file],
40 if not importer.import_from_file(import_params[:file],
40 import_params[:time_limit],
41 import_params[:time_limit],
41 import_params[:memory_limit],
42 import_params[:memory_limit],
42 import_to_db)
43 import_to_db)
43 problem.errors.add_to_base('Import error.')
44 problem.errors.add_to_base('Import error.')
44 end
45 end
45
46
46 return problem, importer.log_msg
47 return problem, importer.log_msg
47 end
48 end
48
49
49 protected
50 protected
50
51
51 def self.to_i_or_default(st, default)
52 def self.to_i_or_default(st, default)
52 if st!=''
53 if st!=''
53 st.to_i
54 st.to_i
54 else
55 else
55 default
56 default
56 end
57 end
57 end
58 end
58
59
59 def self.extract_params_and_check(params, problem)
60 def self.extract_params_and_check(params, problem)
60 time_limit = Problem.to_i_or_default(params[:time_limit],
61 time_limit = Problem.to_i_or_default(params[:time_limit],
61 DEFAULT_TIME_LIMIT)
62 DEFAULT_TIME_LIMIT)
62 memory_limit = Problem.to_i_or_default(params[:memory_limit],
63 memory_limit = Problem.to_i_or_default(params[:memory_limit],
63 DEFAULT_MEMORY_LIMIT)
64 DEFAULT_MEMORY_LIMIT)
64
65
65 if time_limit==0 and time_limit_s!='0'
66 if time_limit==0 and time_limit_s!='0'
66 problem.errors.add_to_base('Time limit format errors.')
67 problem.errors.add_to_base('Time limit format errors.')
67 elsif time_limit<=0 or time_limit >60
68 elsif time_limit<=0 or time_limit >60
68 problem.errors.add_to_base('Time limit out of range.')
69 problem.errors.add_to_base('Time limit out of range.')
69 end
70 end
70
71
71 if memory_limit==0 and memory_limit_s!='0'
72 if memory_limit==0 and memory_limit_s!='0'
72 problem.errors.add_to_base('Memory limit format errors.')
73 problem.errors.add_to_base('Memory limit format errors.')
73 elsif memory_limit<=0 or memory_limit >512
74 elsif memory_limit<=0 or memory_limit >512
74 problem.errors.add_to_base('Memory limit out of range.')
75 problem.errors.add_to_base('Memory limit out of range.')
75 end
76 end
76
77
77 if params[:file]==nil or params[:file]==''
78 if params[:file]==nil or params[:file]==''
78 problem.errors.add_to_base('No testdata file.')
79 problem.errors.add_to_base('No testdata file.')
79 end
80 end
80
81
81 file = params[:file]
82 file = params[:file]
82
83
83 if problem.errors.length!=0
84 if problem.errors.length!=0
84 return problem
85 return problem
85 end
86 end
86
87
87 problem.name = params[:name]
88 problem.name = params[:name]
88 if params[:full_name]!=''
89 if params[:full_name]!=''
89 problem.full_name = params[:full_name]
90 problem.full_name = params[:full_name]
90 else
91 else
91 problem.full_name = params[:name]
92 problem.full_name = params[:name]
92 end
93 end
93
94
94 return {
95 return {
95 :time_limit => time_limit,
96 :time_limit => time_limit,
96 :memory_limit => memory_limit,
97 :memory_limit => memory_limit,
97 :file => file
98 :file => file
98 }
99 }
99 end
100 end
100
101
101 end
102 end
@@ -1,215 +1,217
1 require 'digest/sha1'
1 require 'digest/sha1'
2
2
3 class User < ActiveRecord::Base
3 class User < ActiveRecord::Base
4
4
5 has_and_belongs_to_many :roles
5 has_and_belongs_to_many :roles
6
6
7 has_many :test_requests, :order => "submitted_at DESC"
7 has_many :test_requests, :order => "submitted_at DESC"
8
8
9 has_many :messages,
9 has_many :messages,
10 :class_name => "Message",
10 :class_name => "Message",
11 :foreign_key => "sender_id",
11 :foreign_key => "sender_id",
12 :order => 'created_at DESC'
12 :order => 'created_at DESC'
13
13
14 has_many :replied_messages,
14 has_many :replied_messages,
15 :class_name => "Message",
15 :class_name => "Message",
16 :foreign_key => "receiver_id",
16 :foreign_key => "receiver_id",
17 :order => 'created_at DESC'
17 :order => 'created_at DESC'
18
18
19 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
19 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
20
20
21 belongs_to :site
21 belongs_to :site
22 belongs_to :country
22 belongs_to :country
23
23
24 + has_and_belongs_to_many :contests
25 +
24 named_scope :activated_users, :conditions => {:activated => true}
26 named_scope :activated_users, :conditions => {:activated => true}
25
27
26 validates_presence_of :login
28 validates_presence_of :login
27 validates_uniqueness_of :login
29 validates_uniqueness_of :login
28 validates_format_of :login, :with => /^[\_A-Za-z0-9]+$/
30 validates_format_of :login, :with => /^[\_A-Za-z0-9]+$/
29 validates_length_of :login, :within => 3..30
31 validates_length_of :login, :within => 3..30
30
32
31 validates_presence_of :full_name
33 validates_presence_of :full_name
32 validates_length_of :full_name, :minimum => 1
34 validates_length_of :full_name, :minimum => 1
33
35
34 validates_presence_of :password, :if => :password_required?
36 validates_presence_of :password, :if => :password_required?
35 validates_length_of :password, :within => 4..20, :if => :password_required?
37 validates_length_of :password, :within => 4..20, :if => :password_required?
36 validates_confirmation_of :password, :if => :password_required?
38 validates_confirmation_of :password, :if => :password_required?
37
39
38 validates_format_of :email,
40 validates_format_of :email,
39 :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i,
41 :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i,
40 :if => :email_validation?
42 :if => :email_validation?
41 validate :uniqueness_of_email_from_activated_users,
43 validate :uniqueness_of_email_from_activated_users,
42 :if => :email_validation?
44 :if => :email_validation?
43 validate :enough_time_interval_between_same_email_registrations,
45 validate :enough_time_interval_between_same_email_registrations,
44 :if => :email_validation?
46 :if => :email_validation?
45
47
46 # these are for ytopc
48 # these are for ytopc
47 # disable for now
49 # disable for now
48 #validates_presence_of :province
50 #validates_presence_of :province
49
51
50 attr_accessor :password
52 attr_accessor :password
51
53
52 before_save :encrypt_new_password
54 before_save :encrypt_new_password
53 before_save :assign_default_site
55 before_save :assign_default_site
54
56
55 def self.authenticate(login, password)
57 def self.authenticate(login, password)
56 user = find_by_login(login)
58 user = find_by_login(login)
57 return user if user && user.authenticated?(password)
59 return user if user && user.authenticated?(password)
58 end
60 end
59
61
60 def authenticated?(password)
62 def authenticated?(password)
61 if self.activated
63 if self.activated
62 hashed_password == User.encrypt(password,self.salt)
64 hashed_password == User.encrypt(password,self.salt)
63 else
65 else
64 false
66 false
65 end
67 end
66 end
68 end
67
69
68 def admin?
70 def admin?
69 self.roles.detect {|r| r.name == 'admin' }
71 self.roles.detect {|r| r.name == 'admin' }
70 end
72 end
71
73
72 def email_for_editing
74 def email_for_editing
73 if self.email==nil
75 if self.email==nil
74 "(unknown)"
76 "(unknown)"
75 elsif self.email==''
77 elsif self.email==''
76 "(blank)"
78 "(blank)"
77 else
79 else
78 self.email
80 self.email
79 end
81 end
80 end
82 end
81
83
82 def email_for_editing=(e)
84 def email_for_editing=(e)
83 self.email=e
85 self.email=e
84 end
86 end
85
87
86 def alias_for_editing
88 def alias_for_editing
87 if self.alias==nil
89 if self.alias==nil
88 "(unknown)"
90 "(unknown)"
89 elsif self.alias==''
91 elsif self.alias==''
90 "(blank)"
92 "(blank)"
91 else
93 else
92 self.alias
94 self.alias
93 end
95 end
94 end
96 end
95
97
96 def alias_for_editing=(e)
98 def alias_for_editing=(e)
97 self.alias=e
99 self.alias=e
98 end
100 end
99
101
100 def activation_key
102 def activation_key
101 if self.hashed_password==nil
103 if self.hashed_password==nil
102 encrypt_new_password
104 encrypt_new_password
103 end
105 end
104 Digest::SHA1.hexdigest(self.hashed_password)[0..7]
106 Digest::SHA1.hexdigest(self.hashed_password)[0..7]
105 end
107 end
106
108
107 def verify_activation_key(key)
109 def verify_activation_key(key)
108 key == activation_key
110 key == activation_key
109 end
111 end
110
112
111 def self.random_password(length=5)
113 def self.random_password(length=5)
112 chars = 'abcdefghjkmnopqrstuvwxyz'
114 chars = 'abcdefghjkmnopqrstuvwxyz'
113 password = ''
115 password = ''
114 length.times { password << chars[rand(chars.length - 1)] }
116 length.times { password << chars[rand(chars.length - 1)] }
115 password
117 password
116 end
118 end
117
119
118 def self.find_non_admin_with_prefix(prefix='')
120 def self.find_non_admin_with_prefix(prefix='')
119 users = User.find(:all)
121 users = User.find(:all)
120 return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 }
122 return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 }
121 end
123 end
122
124
123 # Contest information
125 # Contest information
124
126
125 def contest_time_left
127 def contest_time_left
126 if Configuration.contest_mode?
128 if Configuration.contest_mode?
127 return nil if site==nil
129 return nil if site==nil
128 return site.time_left
130 return site.time_left
129 elsif Configuration.indv_contest_mode?
131 elsif Configuration.indv_contest_mode?
130 time_limit = Configuration.contest_time_limit
132 time_limit = Configuration.contest_time_limit
131 if contest_stat==nil
133 if contest_stat==nil
132 return (Time.now.gmtime + time_limit) - Time.now.gmtime
134 return (Time.now.gmtime + time_limit) - Time.now.gmtime
133 else
135 else
134 finish_time = contest_stat.started_at + time_limit
136 finish_time = contest_stat.started_at + time_limit
135 current_time = Time.now.gmtime
137 current_time = Time.now.gmtime
136 if current_time > finish_time
138 if current_time > finish_time
137 return 0
139 return 0
138 else
140 else
139 return finish_time - current_time
141 return finish_time - current_time
140 end
142 end
141 end
143 end
142 else
144 else
143 return nil
145 return nil
144 end
146 end
145 end
147 end
146
148
147 def contest_finished?
149 def contest_finished?
148 if Configuration.contest_mode?
150 if Configuration.contest_mode?
149 return false if site==nil
151 return false if site==nil
150 return site.finished?
152 return site.finished?
151 elsif Configuration.indv_contest_mode?
153 elsif Configuration.indv_contest_mode?
152 time_limit = Configuration.contest_time_limit
154 time_limit = Configuration.contest_time_limit
153
155
154 return false if contest_stat==nil
156 return false if contest_stat==nil
155
157
156 return contest_time_left == 0
158 return contest_time_left == 0
157 else
159 else
158 return false
160 return false
159 end
161 end
160 end
162 end
161
163
162 def contest_started?
164 def contest_started?
163 if Configuration.contest_mode?
165 if Configuration.contest_mode?
164 return true if site==nil
166 return true if site==nil
165 return site.started
167 return site.started
166 else
168 else
167 return true
169 return true
168 end
170 end
169 end
171 end
170
172
171 protected
173 protected
172 def encrypt_new_password
174 def encrypt_new_password
173 return if password.blank?
175 return if password.blank?
174 self.salt = (10+rand(90)).to_s
176 self.salt = (10+rand(90)).to_s
175 self.hashed_password = User.encrypt(self.password,self.salt)
177 self.hashed_password = User.encrypt(self.password,self.salt)
176 end
178 end
177
179
178 def assign_default_site
180 def assign_default_site
179 # have to catch error when migrating (because self.site is not available).
181 # have to catch error when migrating (because self.site is not available).
180 begin
182 begin
181 if self.site==nil
183 if self.site==nil
182 self.site = Site.find_by_name('default')
184 self.site = Site.find_by_name('default')
183 if self.site==nil
185 if self.site==nil
184 self.site = Site.find(1) # when 'default has be renamed'
186 self.site = Site.find(1) # when 'default has be renamed'
185 end
187 end
186 end
188 end
187 rescue
189 rescue
188 end
190 end
189 end
191 end
190
192
191 def password_required?
193 def password_required?
192 self.hashed_password.blank? || !self.password.blank?
194 self.hashed_password.blank? || !self.password.blank?
193 end
195 end
194
196
195 def self.encrypt(string,salt)
197 def self.encrypt(string,salt)
196 Digest::SHA1.hexdigest(salt + string)
198 Digest::SHA1.hexdigest(salt + string)
197 end
199 end
198
200
199 def uniqueness_of_email_from_activated_users
201 def uniqueness_of_email_from_activated_users
200 user = User.activated_users.find_by_email(self.email)
202 user = User.activated_users.find_by_email(self.email)
201 if user and (user.login != self.login)
203 if user and (user.login != self.login)
202 self.errors.add_to_base("Email has already been taken")
204 self.errors.add_to_base("Email has already been taken")
203 end
205 end
204 end
206 end
205
207
206 def enough_time_interval_between_same_email_registrations
208 def enough_time_interval_between_same_email_registrations
207 return if !self.new_record?
209 return if !self.new_record?
208 return if self.activated
210 return if self.activated
209 open_user = User.find_by_email(self.email,
211 open_user = User.find_by_email(self.email,
210 :order => 'created_at DESC')
212 :order => 'created_at DESC')
211 if open_user and open_user.created_at and
213 if open_user and open_user.created_at and
212 (open_user.created_at > Time.now.gmtime - 5.minutes)
214 (open_user.created_at > Time.now.gmtime - 5.minutes)
213 self.errors.add_to_base("There are already unactivated registrations with this e-mail address (please wait for 5 minutes)")
215 self.errors.add_to_base("There are already unactivated registrations with this e-mail address (please wait for 5 minutes)")
214 end
216 end
215 end
217 end
@@ -1,240 +1,250
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of Active Record to incrementally modify your database, and
2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 # then regenerate this schema definition.
3 # then regenerate this schema definition.
4 #
4 #
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 # to create the application database on another system, you should be using db:schema:load, not running
6 # to create the application database on another system, you should be using db:schema:load, not running
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 #
9 #
10 # It's strongly recommended to check this file into your version control system.
10 # It's strongly recommended to check this file into your version control system.
11
11
12 - ActiveRecord::Schema.define(:version => 20100216105730) do
12 + ActiveRecord::Schema.define(:version => 20100216162940) do
13
13
14 create_table "announcements", :force => true do |t|
14 create_table "announcements", :force => true do |t|
15 t.string "author"
15 t.string "author"
16 t.text "body"
16 t.text "body"
17 t.boolean "published"
17 t.boolean "published"
18 t.datetime "created_at"
18 t.datetime "created_at"
19 t.datetime "updated_at"
19 t.datetime "updated_at"
20 t.boolean "frontpage", :default => false
20 t.boolean "frontpage", :default => false
21 t.boolean "contest_only", :default => false
21 t.boolean "contest_only", :default => false
22 t.string "title"
22 t.string "title"
23 end
23 end
24
24
25 create_table "codejom_statuses", :force => true do |t|
25 create_table "codejom_statuses", :force => true do |t|
26 t.integer "user_id"
26 t.integer "user_id"
27 t.boolean "alive"
27 t.boolean "alive"
28 t.integer "num_problems_passed"
28 t.integer "num_problems_passed"
29 t.datetime "created_at"
29 t.datetime "created_at"
30 t.datetime "updated_at"
30 t.datetime "updated_at"
31 end
31 end
32
32
33 create_table "configurations", :force => true do |t|
33 create_table "configurations", :force => true do |t|
34 t.string "key"
34 t.string "key"
35 t.string "value_type"
35 t.string "value_type"
36 t.string "value"
36 t.string "value"
37 t.datetime "created_at"
37 t.datetime "created_at"
38 t.datetime "updated_at"
38 t.datetime "updated_at"
39 t.text "description"
39 t.text "description"
40 end
40 end
41
41
42 create_table "contests", :force => true do |t|
42 create_table "contests", :force => true do |t|
43 t.string "title"
43 t.string "title"
44 t.boolean "enabled"
44 t.boolean "enabled"
45 t.datetime "created_at"
45 t.datetime "created_at"
46 t.datetime "updated_at"
46 t.datetime "updated_at"
47 end
47 end
48
48
49 + create_table "contests_problems", :id => false, :force => true do |t|
50 + t.integer "contest_id"
51 + t.integer "problem_id"
52 + end
53 +
54 + create_table "contests_users", :id => false, :force => true do |t|
55 + t.integer "contest_id"
56 + t.integer "user_id"
57 + end
58 +
49 create_table "countries", :force => true do |t|
59 create_table "countries", :force => true do |t|
50 t.string "name"
60 t.string "name"
51 t.datetime "created_at"
61 t.datetime "created_at"
52 t.datetime "updated_at"
62 t.datetime "updated_at"
53 end
63 end
54
64
55 create_table "descriptions", :force => true do |t|
65 create_table "descriptions", :force => true do |t|
56 t.text "body"
66 t.text "body"
57 t.boolean "markdowned"
67 t.boolean "markdowned"
58 t.datetime "created_at"
68 t.datetime "created_at"
59 t.datetime "updated_at"
69 t.datetime "updated_at"
60 end
70 end
61
71
62 create_table "grader_processes", :force => true do |t|
72 create_table "grader_processes", :force => true do |t|
63 t.string "host", :limit => 20
73 t.string "host", :limit => 20
64 t.integer "pid"
74 t.integer "pid"
65 t.string "mode"
75 t.string "mode"
66 t.boolean "active"
76 t.boolean "active"
67 t.datetime "created_at"
77 t.datetime "created_at"
68 t.datetime "updated_at"
78 t.datetime "updated_at"
69 t.integer "task_id"
79 t.integer "task_id"
70 t.string "task_type"
80 t.string "task_type"
71 t.boolean "terminated"
81 t.boolean "terminated"
72 end
82 end
73
83
74 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
84 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
75
85
76 create_table "languages", :force => true do |t|
86 create_table "languages", :force => true do |t|
77 t.string "name", :limit => 10
87 t.string "name", :limit => 10
78 t.string "pretty_name"
88 t.string "pretty_name"
79 t.string "ext", :limit => 10
89 t.string "ext", :limit => 10
80 t.string "common_ext"
90 t.string "common_ext"
81 end
91 end
82
92
83 create_table "messages", :force => true do |t|
93 create_table "messages", :force => true do |t|
84 t.integer "sender_id"
94 t.integer "sender_id"
85 t.integer "receiver_id"
95 t.integer "receiver_id"
86 t.integer "replying_message_id"
96 t.integer "replying_message_id"
87 t.text "body"
97 t.text "body"
88 t.boolean "replied"
98 t.boolean "replied"
89 t.datetime "created_at"
99 t.datetime "created_at"
90 t.datetime "updated_at"
100 t.datetime "updated_at"
91 end
101 end
92
102
93 create_table "problems", :force => true do |t|
103 create_table "problems", :force => true do |t|
94 t.string "name", :limit => 30
104 t.string "name", :limit => 30
95 t.string "full_name"
105 t.string "full_name"
96 t.integer "full_score"
106 t.integer "full_score"
97 t.date "date_added"
107 t.date "date_added"
98 t.boolean "available"
108 t.boolean "available"
99 t.string "url"
109 t.string "url"
100 t.integer "description_id"
110 t.integer "description_id"
101 t.boolean "test_allowed"
111 t.boolean "test_allowed"
102 t.boolean "output_only"
112 t.boolean "output_only"
103 t.integer "level", :default => 0
113 t.integer "level", :default => 0
104 t.datetime "updated_at"
114 t.datetime "updated_at"
105 end
115 end
106
116
107 create_table "rights", :force => true do |t|
117 create_table "rights", :force => true do |t|
108 t.string "name"
118 t.string "name"
109 t.string "controller"
119 t.string "controller"
110 t.string "action"
120 t.string "action"
111 end
121 end
112
122
113 create_table "rights_roles", :id => false, :force => true do |t|
123 create_table "rights_roles", :id => false, :force => true do |t|
114 t.integer "right_id"
124 t.integer "right_id"
115 t.integer "role_id"
125 t.integer "role_id"
116 end
126 end
117
127
118 add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
128 add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
119
129
120 create_table "roles", :force => true do |t|
130 create_table "roles", :force => true do |t|
121 t.string "name"
131 t.string "name"
122 end
132 end
123
133
124 create_table "roles_users", :id => false, :force => true do |t|
134 create_table "roles_users", :id => false, :force => true do |t|
125 t.integer "role_id"
135 t.integer "role_id"
126 t.integer "user_id"
136 t.integer "user_id"
127 end
137 end
128
138
129 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
139 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
130
140
131 create_table "sessions", :force => true do |t|
141 create_table "sessions", :force => true do |t|
132 t.string "session_id"
142 t.string "session_id"
133 t.text "data"
143 t.text "data"
134 t.datetime "updated_at"
144 t.datetime "updated_at"
135 end
145 end
136
146
137 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
147 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
138 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
148 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
139
149
140 create_table "sites", :force => true do |t|
150 create_table "sites", :force => true do |t|
141 t.string "name"
151 t.string "name"
142 t.boolean "started"
152 t.boolean "started"
143 t.datetime "start_time"
153 t.datetime "start_time"
144 t.datetime "created_at"
154 t.datetime "created_at"
145 t.datetime "updated_at"
155 t.datetime "updated_at"
146 t.integer "country_id"
156 t.integer "country_id"
147 t.string "password"
157 t.string "password"
148 end
158 end
149
159
150 create_table "submission_statuses", :force => true do |t|
160 create_table "submission_statuses", :force => true do |t|
151 t.integer "user_id"
161 t.integer "user_id"
152 t.integer "problem_id"
162 t.integer "problem_id"
153 t.boolean "passed"
163 t.boolean "passed"
154 t.integer "submission_count"
164 t.integer "submission_count"
155 t.datetime "created_at"
165 t.datetime "created_at"
156 t.datetime "updated_at"
166 t.datetime "updated_at"
157 end
167 end
158
168
159 create_table "submissions", :force => true do |t|
169 create_table "submissions", :force => true do |t|
160 t.integer "user_id"
170 t.integer "user_id"
161 t.integer "problem_id"
171 t.integer "problem_id"
162 t.integer "language_id"
172 t.integer "language_id"
163 t.text "source"
173 t.text "source"
164 t.binary "binary"
174 t.binary "binary"
165 t.datetime "submitted_at"
175 t.datetime "submitted_at"
166 t.datetime "compiled_at"
176 t.datetime "compiled_at"
167 t.text "compiler_message"
177 t.text "compiler_message"
168 t.datetime "graded_at"
178 t.datetime "graded_at"
169 t.integer "points"
179 t.integer "points"
170 t.text "grader_comment"
180 t.text "grader_comment"
171 t.integer "number"
181 t.integer "number"
172 t.string "source_filename"
182 t.string "source_filename"
173 end
183 end
174
184
175 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
185 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
176 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
186 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
177
187
178 create_table "tasks", :force => true do |t|
188 create_table "tasks", :force => true do |t|
179 t.integer "submission_id"
189 t.integer "submission_id"
180 t.datetime "created_at"
190 t.datetime "created_at"
181 t.integer "status"
191 t.integer "status"
182 t.datetime "updated_at"
192 t.datetime "updated_at"
183 end
193 end
184
194
185 create_table "test_pair_assignments", :force => true do |t|
195 create_table "test_pair_assignments", :force => true do |t|
186 t.integer "user_id"
196 t.integer "user_id"
187 t.integer "problem_id"
197 t.integer "problem_id"
188 t.integer "test_pair_id"
198 t.integer "test_pair_id"
189 t.integer "test_pair_number"
199 t.integer "test_pair_number"
190 t.integer "request_number"
200 t.integer "request_number"
191 t.datetime "created_at"
201 t.datetime "created_at"
192 t.datetime "updated_at"
202 t.datetime "updated_at"
193 t.boolean "submitted"
203 t.boolean "submitted"
194 end
204 end
195
205
196 create_table "test_pairs", :force => true do |t|
206 create_table "test_pairs", :force => true do |t|
197 t.integer "problem_id"
207 t.integer "problem_id"
198 t.text "input", :limit => 16777215
208 t.text "input", :limit => 16777215
199 t.text "solution", :limit => 16777215
209 t.text "solution", :limit => 16777215
200 t.datetime "created_at"
210 t.datetime "created_at"
201 t.datetime "updated_at"
211 t.datetime "updated_at"
202 t.integer "number"
212 t.integer "number"
203 end
213 end
204
214
205 create_table "test_requests", :force => true do |t|
215 create_table "test_requests", :force => true do |t|
206 t.integer "user_id"
216 t.integer "user_id"
207 t.integer "problem_id"
217 t.integer "problem_id"
208 t.integer "submission_id"
218 t.integer "submission_id"
209 t.string "input_file_name"
219 t.string "input_file_name"
210 t.string "output_file_name"
220 t.string "output_file_name"
211 t.string "running_stat"
221 t.string "running_stat"
212 t.integer "status"
222 t.integer "status"
213 t.datetime "updated_at"
223 t.datetime "updated_at"
214 t.datetime "submitted_at"
224 t.datetime "submitted_at"
215 t.datetime "compiled_at"
225 t.datetime "compiled_at"
216 t.text "compiler_message"
226 t.text "compiler_message"
217 t.datetime "graded_at"
227 t.datetime "graded_at"
218 t.string "grader_comment"
228 t.string "grader_comment"
219 t.datetime "created_at"
229 t.datetime "created_at"
220 t.float "running_time"
230 t.float "running_time"
221 t.string "exit_status"
231 t.string "exit_status"
222 t.integer "memory_usage"
232 t.integer "memory_usage"
223 end
233 end
224
234
225 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
235 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
226
236
227 create_table "user_contest_stats", :force => true do |t|
237 create_table "user_contest_stats", :force => true do |t|
228 t.integer "user_id"
238 t.integer "user_id"
229 t.datetime "started_at"
239 t.datetime "started_at"
230 t.datetime "created_at"
240 t.datetime "created_at"
231 t.datetime "updated_at"
241 t.datetime "updated_at"
232 end
242 end
233
243
234 create_table "users", :force => true do |t|
244 create_table "users", :force => true do |t|
235 t.string "login", :limit => 50
245 t.string "login", :limit => 50
236 t.string "full_name"
246 t.string "full_name"
237 t.string "hashed_password"
247 t.string "hashed_password"
238 t.string "salt", :limit => 5
248 t.string "salt", :limit => 5
239 t.string "alias"
249 t.string "alias"
240 t.string "email"
250 t.string "email"
You need to be logged in to leave comments. Login now