Description:
[web] import from site
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@224 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r106:695a33fa7e55 - - 12 files changed: 141 inserted, 4 deleted
@@ -0,0 +1,6 | |||||
|
|
1 | + return to | ||
|
|
2 | + = link_to '[user list]', :action => 'list' | ||
|
|
3 | + | ||
|
|
4 | + %h3 Import log | ||
|
|
5 | + | ||
|
|
6 | + = simple_format(@import_log) |
@@ -0,0 +1,12 | |||||
|
|
1 | + class CreateCountries < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + create_table :countries do |t| | ||
|
|
4 | + t.column :name, :string | ||
|
|
5 | + t.timestamps | ||
|
|
6 | + end | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def self.down | ||
|
|
10 | + drop_table :countries | ||
|
|
11 | + end | ||
|
|
12 | + end |
@@ -0,0 +1,15 | |||||
|
|
1 | + class AddCountryToSitesAndUsers < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + add_column 'sites', 'country_id', :integer | ||
|
|
4 | + add_column 'sites', 'password', :string | ||
|
|
5 | + | ||
|
|
6 | + add_column 'users', 'country_id', :integer | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def self.down | ||
|
|
10 | + remove_column 'users', 'country_id' | ||
|
|
11 | + | ||
|
|
12 | + remove_column 'sites', 'country_id' | ||
|
|
13 | + remove_column 'sites', 'password' | ||
|
|
14 | + end | ||
|
|
15 | + end |
@@ -0,0 +1,7 | |||||
|
|
1 | + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
|
2 | + | ||
|
|
3 | + # one: | ||
|
|
4 | + # column: value | ||
|
|
5 | + # | ||
|
|
6 | + # two: | ||
|
|
7 | + # column: value |
@@ -0,0 +1,8 | |||||
|
|
1 | + require File.dirname(__FILE__) + '/../test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class CountryTest < ActiveSupport::TestCase | ||
|
|
4 | + # Replace this with your real tests. | ||
|
|
5 | + def test_truth | ||
|
|
6 | + assert true | ||
|
|
7 | + end | ||
|
|
8 | + end |
@@ -67,25 +67,92 | |||||
|
67 | def destroy |
|
67 | def destroy |
|
68 | User.find(params[:id]).destroy |
|
68 | User.find(params[:id]).destroy |
|
69 | redirect_to :action => 'list' |
|
69 | redirect_to :action => 'list' |
|
70 | end |
|
70 | end |
|
71 |
|
71 | ||
|
72 | def user_stat |
|
72 | def user_stat |
|
73 | @problems = Problem.find_available_problems |
|
73 | @problems = Problem.find_available_problems |
|
74 | @users = User.find(:all) |
|
74 | @users = User.find(:all) |
|
75 | @scorearray = Array.new |
|
75 | @scorearray = Array.new |
|
76 | @users.each do |u| |
|
76 | @users.each do |u| |
|
77 | ustat = Array.new |
|
77 | ustat = Array.new |
|
78 | ustat[0] = u.login |
|
78 | ustat[0] = u.login |
|
79 | ustat[1] = u.full_name |
|
79 | ustat[1] = u.full_name |
|
80 | @problems.each do |p| |
|
80 | @problems.each do |p| |
|
81 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
81 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
82 | if (sub!=nil) and (sub.points!=nil) |
|
82 | if (sub!=nil) and (sub.points!=nil) |
|
83 | ustat << [sub.points, (sub.points>=p.full_score)] |
|
83 | ustat << [sub.points, (sub.points>=p.full_score)] |
|
84 | else |
|
84 | else |
|
85 | ustat << [0,false] |
|
85 | ustat << [0,false] |
|
86 | end |
|
86 | end |
|
87 | end |
|
87 | end |
|
88 | @scorearray << ustat |
|
88 | @scorearray << ustat |
|
89 | end |
|
89 | end |
|
90 | end |
|
90 | end |
|
|
91 | + | ||
|
|
92 | + def import | ||
|
|
93 | + if params[:file]=='' | ||
|
|
94 | + flash[:notice] = 'Error importing no file' | ||
|
|
95 | + redirect_to :action => 'list' and return | ||
|
91 | end |
|
96 | end |
|
|
97 | + import_from_file(params[:file]) | ||
|
|
98 | + end | ||
|
|
99 | + | ||
|
|
100 | + protected | ||
|
|
101 | + | ||
|
|
102 | + def import_from_file(f) | ||
|
|
103 | + data_hash = YAML.load(f) | ||
|
|
104 | + @import_log = "" | ||
|
|
105 | + | ||
|
|
106 | + country_data = data_hash[:countries] | ||
|
|
107 | + site_data = data_hash[:sites] | ||
|
|
108 | + user_data = data_hash[:users] | ||
|
|
109 | + | ||
|
|
110 | + # import country | ||
|
|
111 | + countries = {} | ||
|
|
112 | + country_data.each_pair do |id,country| | ||
|
|
113 | + c = Country.find_by_name(country[:name]) | ||
|
|
114 | + if c!=nil | ||
|
|
115 | + countries[id] = c | ||
|
|
116 | + @import_log << "Found #{country[:name]}\n" | ||
|
|
117 | + else | ||
|
|
118 | + countries[id] = Country.new(:name => country[:name]) | ||
|
|
119 | + countries[id].save | ||
|
|
120 | + @import_log << "Created #{country[:name]}\n" | ||
|
|
121 | + end | ||
|
|
122 | + end | ||
|
|
123 | + | ||
|
|
124 | + # import sites | ||
|
|
125 | + sites = {} | ||
|
|
126 | + site_data.each_pair do |id,site| | ||
|
|
127 | + s = Site.find_by_name(site[:name]) | ||
|
|
128 | + if s!=nil | ||
|
|
129 | + @import_log << "Found #{site[:name]}\n" | ||
|
|
130 | + else | ||
|
|
131 | + s = Site.new(:name => site[:name]) | ||
|
|
132 | + @import_log << "Created #{site[:name]}\n" | ||
|
|
133 | + end | ||
|
|
134 | + s.password = site[:password] | ||
|
|
135 | + s.country = countries[site[:country_id]] | ||
|
|
136 | + s.save | ||
|
|
137 | + sites[id] = s | ||
|
|
138 | + end | ||
|
|
139 | + | ||
|
|
140 | + # import users | ||
|
|
141 | + user_data.each_pair do |id,user| | ||
|
|
142 | + u = User.find_by_login(user[:login]) | ||
|
|
143 | + if u!=nil | ||
|
|
144 | + @import_log << "Found #{user[:login]}\n" | ||
|
|
145 | + else | ||
|
|
146 | + u = User.new(:login => user[:login]) | ||
|
|
147 | + @import_log << "Created #{user[:login]}\n" | ||
|
|
148 | + end | ||
|
|
149 | + u.full_name = user[:name] | ||
|
|
150 | + u.password = user[:password] | ||
|
|
151 | + u.country = countries[user[:country_id]] | ||
|
|
152 | + u.site = sites[user[:site_id]] | ||
|
|
153 | + u.save | ||
|
|
154 | + end | ||
|
|
155 | + | ||
|
|
156 | + end | ||
|
|
157 | + | ||
|
|
158 | + end |
@@ -1,24 +1,27 | |||||
|
1 | class Site < ActiveRecord::Base |
|
1 | class Site < ActiveRecord::Base |
|
2 |
|
2 | ||
|
|
3 | + belongs_to :country | ||
|
|
4 | + has_many :users | ||
|
|
5 | + | ||
|
3 | def clear_start_time_if_not_started |
|
6 | def clear_start_time_if_not_started |
|
4 | if !self.started |
|
7 | if !self.started |
|
5 | self.start_time = nil |
|
8 | self.start_time = nil |
|
6 | end |
|
9 | end |
|
7 | end |
|
10 | end |
|
8 |
|
11 | ||
|
9 | def finished? |
|
12 | def finished? |
|
10 | if !self.started |
|
13 | if !self.started |
|
11 | return false |
|
14 | return false |
|
12 | end |
|
15 | end |
|
13 |
|
16 | ||
|
14 | contest_time = Configuration['contest.time_limit'] |
|
17 | contest_time = Configuration['contest.time_limit'] |
|
15 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
18 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
16 | h = tmatch[1].to_i |
|
19 | h = tmatch[1].to_i |
|
17 | m = tmatch[2].to_i |
|
20 | m = tmatch[2].to_i |
|
18 | return Time.now > (self.start_time + h.hour + m.minute) |
|
21 | return Time.now > (self.start_time + h.hour + m.minute) |
|
19 | else |
|
22 | else |
|
20 | false |
|
23 | false |
|
21 | end |
|
24 | end |
|
22 | end |
|
25 | end |
|
23 |
|
26 | ||
|
24 | end |
|
27 | end |
@@ -1,43 +1,44 | |||||
|
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 | belongs_to :site |
|
19 | belongs_to :site |
|
|
20 | + belongs_to :country | ||
|
20 |
|
21 | ||
|
21 | validates_presence_of :login |
|
22 | validates_presence_of :login |
|
22 | validates_presence_of :full_name |
|
23 | validates_presence_of :full_name |
|
23 | validates_length_of :full_name, :minimum => 1 |
|
24 | validates_length_of :full_name, :minimum => 1 |
|
24 |
|
25 | ||
|
25 | validates_presence_of :password, :if => :password_required? |
|
26 | validates_presence_of :password, :if => :password_required? |
|
26 | validates_length_of :password, :within => 4..20, :if => :password_required? |
|
27 | validates_length_of :password, :within => 4..20, :if => :password_required? |
|
27 | validates_confirmation_of :password, :if => :password_required? |
|
28 | validates_confirmation_of :password, :if => :password_required? |
|
28 |
|
29 | ||
|
29 | attr_accessor :password |
|
30 | attr_accessor :password |
|
30 |
|
31 | ||
|
31 | before_save :encrypt_new_password |
|
32 | before_save :encrypt_new_password |
|
32 |
|
33 | ||
|
33 | def self.authenticate(login, password) |
|
34 | def self.authenticate(login, password) |
|
34 | user = find_by_login(login) |
|
35 | user = find_by_login(login) |
|
35 | return user if user && user.authenticated?(password) |
|
36 | return user if user && user.authenticated?(password) |
|
36 | end |
|
37 | end |
|
37 |
|
38 | ||
|
38 | def authenticated?(password) |
|
39 | def authenticated?(password) |
|
39 | hashed_password == User.encrypt(password,self.salt) |
|
40 | hashed_password == User.encrypt(password,self.salt) |
|
40 | end |
|
41 | end |
|
41 |
|
42 | ||
|
42 | def admin? |
|
43 | def admin? |
|
43 | self.roles.detect {|r| r.name == 'admin' } |
|
44 | self.roles.detect {|r| r.name == 'admin' } |
@@ -1,14 +1,14 | |||||
|
1 | = user_title_bar(@user) |
|
1 | = user_title_bar(@user) |
|
2 |
|
2 | ||
|
3 | %h3 Your Messages |
|
3 | %h3 Your Messages |
|
4 |
|
4 | ||
|
5 | - form_for 'message', nil, :url => { :action => 'create'} do |f| |
|
5 | - form_for 'message', nil, :url => { :action => 'create'} do |f| |
|
6 | %p |
|
6 | %p |
|
7 | - %b New message |
|
7 | + %b New clarification request |
|
8 | = submit_tag "Post" |
|
8 | = submit_tag "Post" |
|
9 | %br/ |
|
9 | %br/ |
|
10 | = f.text_area :body, :rows => 5, :cols => 100 |
|
10 | = f.text_area :body, :rows => 5, :cols => 100 |
|
11 |
|
11 | ||
|
12 | %hr/ |
|
12 | %hr/ |
|
13 |
|
13 | ||
|
14 | = render :partial => 'message', :collection => @messages, :locals => {:reply => false} |
|
14 | = render :partial => 'message', :collection => @messages, :locals => {:reply => false} |
@@ -1,53 +1,57 | |||||
|
1 | <% content_for :head do %> |
|
1 | <% content_for :head do %> |
|
2 | <%= stylesheet_link_tag 'scaffold' %> |
|
2 | <%= stylesheet_link_tag 'scaffold' %> |
|
3 | <% end %> |
|
3 | <% end %> |
|
4 |
|
4 | ||
|
5 | <h1>Listing users</h1> |
|
5 | <h1>Listing users</h1> |
|
6 |
|
6 | ||
|
7 | - <div style="border: solid 1px; margin: 2px"> |
|
7 | + <div class="submitbox"> |
|
8 | <b>Quick add</b> |
|
8 | <b>Quick add</b> |
|
9 | <% form_tag :action => 'create' do %> |
|
9 | <% form_tag :action => 'create' do %> |
|
10 | <table border="0"> |
|
10 | <table border="0"> |
|
11 | <tr> |
|
11 | <tr> |
|
12 | <td><label for="user_login">Login</label></td> |
|
12 | <td><label for="user_login">Login</label></td> |
|
13 | <td><label for="user_full_name">Full name</label></td> |
|
13 | <td><label for="user_full_name">Full name</label></td> |
|
14 | <td><label for="user_alias">Alias</label></td> |
|
14 | <td><label for="user_alias">Alias</label></td> |
|
15 | <td><label for="user_password">Password</label></td> |
|
15 | <td><label for="user_password">Password</label></td> |
|
16 | <td><label for="user_password_confirmation">confirm</label></td> |
|
16 | <td><label for="user_password_confirmation">confirm</label></td> |
|
17 | </tr> |
|
17 | </tr> |
|
18 | <tr> |
|
18 | <tr> |
|
19 | <td><%= text_field 'user', 'login', :size => 10 %></td> |
|
19 | <td><%= text_field 'user', 'login', :size => 10 %></td> |
|
20 | <td><%= text_field 'user', 'full_name', :size => 30 %></td> |
|
20 | <td><%= text_field 'user', 'full_name', :size => 30 %></td> |
|
21 | <td><%= text_field 'user', 'alias', :size => 10 %></td> |
|
21 | <td><%= text_field 'user', 'alias', :size => 10 %></td> |
|
22 | <td><%= password_field 'user', 'password', :size => 10 %></td> |
|
22 | <td><%= password_field 'user', 'password', :size => 10 %></td> |
|
23 | <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td> |
|
23 | <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td> |
|
24 | <td><%= submit_tag "Create" %></td> |
|
24 | <td><%= submit_tag "Create" %></td> |
|
25 | </tr></table> |
|
25 | </tr></table> |
|
26 | <% end %> |
|
26 | <% end %> |
|
|
27 | + <br/> | ||
|
|
28 | + <b>Import from site management</b> | ||
|
|
29 | + <% form_tag({:action => 'import'}, :multipart => true) do %> | ||
|
|
30 | + File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> | ||
|
|
31 | + <% end %> | ||
|
27 |
|
32 | ||
|
28 | </div> |
|
33 | </div> |
|
29 | - |
|
||
|
30 | <table> |
|
34 | <table> |
|
31 | <tr> |
|
35 | <tr> |
|
32 | <% for column in User.content_columns %> |
|
36 | <% for column in User.content_columns %> |
|
33 | <th><%= column.human_name %></th> |
|
37 | <th><%= column.human_name %></th> |
|
34 | <% end %> |
|
38 | <% end %> |
|
35 | </tr> |
|
39 | </tr> |
|
36 |
|
40 | ||
|
37 | <% for user in @users %> |
|
41 | <% for user in @users %> |
|
38 | <tr> |
|
42 | <tr> |
|
39 | <% for column in User.content_columns %> |
|
43 | <% for column in User.content_columns %> |
|
40 | <td><%=h user.send(column.name) %></td> |
|
44 | <td><%=h user.send(column.name) %></td> |
|
41 | <% end %> |
|
45 | <% end %> |
|
42 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
46 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
43 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
47 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
44 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
48 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
45 | </tr> |
|
49 | </tr> |
|
46 | <% end %> |
|
50 | <% end %> |
|
47 | </table> |
|
51 | </table> |
|
48 |
|
52 | ||
|
49 |
|
53 | ||
|
50 | <br /> |
|
54 | <br /> |
|
51 |
|
55 | ||
|
52 | <%= link_to 'New user', :action => 'new' %> |
|
56 | <%= link_to 'New user', :action => 'new' %> |
|
53 | <%= link_to 'New list of users', :action => 'new_list' %> |
|
57 | <%= link_to 'New list of users', :action => 'new_list' %> |
@@ -1,53 +1,59 | |||||
|
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 ActiveRecord to incrementally modify your database, and |
|
2 | # please use the migrations feature of ActiveRecord 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 => 3 |
|
12 | + ActiveRecord::Schema.define(:version => 35) 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 | end |
|
20 | end |
|
21 |
|
21 | ||
|
22 | create_table "configurations", :force => true do |t| |
|
22 | create_table "configurations", :force => true do |t| |
|
23 | t.string "key" |
|
23 | t.string "key" |
|
24 | t.string "value_type" |
|
24 | t.string "value_type" |
|
25 | t.string "value" |
|
25 | t.string "value" |
|
26 | t.datetime "created_at" |
|
26 | t.datetime "created_at" |
|
27 | t.datetime "updated_at" |
|
27 | t.datetime "updated_at" |
|
28 | end |
|
28 | end |
|
29 |
|
29 | ||
|
|
30 | + create_table "countries", :force => true do |t| | ||
|
|
31 | + t.string "name" | ||
|
|
32 | + t.datetime "created_at" | ||
|
|
33 | + t.datetime "updated_at" | ||
|
|
34 | + end | ||
|
|
35 | + | ||
|
30 | create_table "descriptions", :force => true do |t| |
|
36 | create_table "descriptions", :force => true do |t| |
|
31 | t.text "body" |
|
37 | t.text "body" |
|
32 | t.boolean "markdowned" |
|
38 | t.boolean "markdowned" |
|
33 | t.datetime "created_at" |
|
39 | t.datetime "created_at" |
|
34 | t.datetime "updated_at" |
|
40 | t.datetime "updated_at" |
|
35 | end |
|
41 | end |
|
36 |
|
42 | ||
|
37 | create_table "grader_processes", :force => true do |t| |
|
43 | create_table "grader_processes", :force => true do |t| |
|
38 | t.string "host", :limit => 20 |
|
44 | t.string "host", :limit => 20 |
|
39 | t.integer "pid" |
|
45 | t.integer "pid" |
|
40 | t.string "mode" |
|
46 | t.string "mode" |
|
41 | t.boolean "active" |
|
47 | t.boolean "active" |
|
42 | t.datetime "created_at" |
|
48 | t.datetime "created_at" |
|
43 | t.datetime "updated_at" |
|
49 | t.datetime "updated_at" |
|
44 | t.integer "task_id" |
|
50 | t.integer "task_id" |
|
45 | t.string "task_type" |
|
51 | t.string "task_type" |
|
46 | end |
|
52 | end |
|
47 |
|
53 | ||
|
48 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
54 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
49 |
|
55 | ||
|
50 | create_table "languages", :force => true do |t| |
|
56 | create_table "languages", :force => true do |t| |
|
51 | t.string "name", :limit => 10 |
|
57 | t.string "name", :limit => 10 |
|
52 | t.string "pretty_name" |
|
58 | t.string "pretty_name" |
|
53 | t.string "ext", :limit => 10 |
|
59 | t.string "ext", :limit => 10 |
@@ -93,48 +99,50 | |||||
|
93 | end |
|
99 | end |
|
94 |
|
100 | ||
|
95 | create_table "roles_users", :id => false, :force => true do |t| |
|
101 | create_table "roles_users", :id => false, :force => true do |t| |
|
96 | t.integer "role_id" |
|
102 | t.integer "role_id" |
|
97 | t.integer "user_id" |
|
103 | t.integer "user_id" |
|
98 | end |
|
104 | end |
|
99 |
|
105 | ||
|
100 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
106 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
101 |
|
107 | ||
|
102 | create_table "sessions", :force => true do |t| |
|
108 | create_table "sessions", :force => true do |t| |
|
103 | t.string "session_id" |
|
109 | t.string "session_id" |
|
104 | t.text "data" |
|
110 | t.text "data" |
|
105 | t.datetime "updated_at" |
|
111 | t.datetime "updated_at" |
|
106 | end |
|
112 | end |
|
107 |
|
113 | ||
|
108 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
114 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
109 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
115 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
110 |
|
116 | ||
|
111 | create_table "sites", :force => true do |t| |
|
117 | create_table "sites", :force => true do |t| |
|
112 | t.string "name" |
|
118 | t.string "name" |
|
113 | t.boolean "started" |
|
119 | t.boolean "started" |
|
114 | t.datetime "start_time" |
|
120 | t.datetime "start_time" |
|
115 | t.datetime "created_at" |
|
121 | t.datetime "created_at" |
|
116 | t.datetime "updated_at" |
|
122 | t.datetime "updated_at" |
|
|
123 | + t.integer "country_id" | ||
|
|
124 | + t.string "password" | ||
|
117 | end |
|
125 | end |
|
118 |
|
126 | ||
|
119 | create_table "submissions", :force => true do |t| |
|
127 | create_table "submissions", :force => true do |t| |
|
120 | t.integer "user_id" |
|
128 | t.integer "user_id" |
|
121 | t.integer "problem_id" |
|
129 | t.integer "problem_id" |
|
122 | t.integer "language_id" |
|
130 | t.integer "language_id" |
|
123 | t.text "source" |
|
131 | t.text "source" |
|
124 | t.binary "binary" |
|
132 | t.binary "binary" |
|
125 | t.datetime "submitted_at" |
|
133 | t.datetime "submitted_at" |
|
126 | t.datetime "compiled_at" |
|
134 | t.datetime "compiled_at" |
|
127 | t.text "compiler_message" |
|
135 | t.text "compiler_message" |
|
128 | t.datetime "graded_at" |
|
136 | t.datetime "graded_at" |
|
129 | t.integer "points" |
|
137 | t.integer "points" |
|
130 | t.text "grader_comment" |
|
138 | t.text "grader_comment" |
|
131 | t.integer "number" |
|
139 | t.integer "number" |
|
132 | t.string "source_filename" |
|
140 | t.string "source_filename" |
|
133 | end |
|
141 | end |
|
134 |
|
142 | ||
|
135 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
143 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
136 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
144 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
137 |
|
145 | ||
|
138 | create_table "tasks", :force => true do |t| |
|
146 | create_table "tasks", :force => true do |t| |
|
139 | t.integer "submission_id" |
|
147 | t.integer "submission_id" |
|
140 | t.datetime "created_at" |
|
148 | t.datetime "created_at" |
@@ -151,29 +159,30 | |||||
|
151 | t.string "running_stat" |
|
159 | t.string "running_stat" |
|
152 | t.integer "status" |
|
160 | t.integer "status" |
|
153 | t.datetime "updated_at" |
|
161 | t.datetime "updated_at" |
|
154 | t.datetime "submitted_at" |
|
162 | t.datetime "submitted_at" |
|
155 | t.datetime "compiled_at" |
|
163 | t.datetime "compiled_at" |
|
156 | t.text "compiler_message" |
|
164 | t.text "compiler_message" |
|
157 | t.datetime "graded_at" |
|
165 | t.datetime "graded_at" |
|
158 | t.string "grader_comment" |
|
166 | t.string "grader_comment" |
|
159 | t.datetime "created_at" |
|
167 | t.datetime "created_at" |
|
160 | t.float "running_time" |
|
168 | t.float "running_time" |
|
161 | t.string "exit_status" |
|
169 | t.string "exit_status" |
|
162 | t.integer "memory_usage" |
|
170 | t.integer "memory_usage" |
|
163 | end |
|
171 | end |
|
164 |
|
172 | ||
|
165 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
173 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
166 |
|
174 | ||
|
167 | create_table "users", :force => true do |t| |
|
175 | create_table "users", :force => true do |t| |
|
168 | t.string "login", :limit => 10 |
|
176 | t.string "login", :limit => 10 |
|
169 | t.string "full_name" |
|
177 | t.string "full_name" |
|
170 | t.string "hashed_password" |
|
178 | t.string "hashed_password" |
|
171 | t.string "salt", :limit => 5 |
|
179 | t.string "salt", :limit => 5 |
|
172 | t.string "alias" |
|
180 | t.string "alias" |
|
173 | t.string "email" |
|
181 | t.string "email" |
|
174 | t.integer "site_id" |
|
182 | t.integer "site_id" |
|
|
183 | + t.integer "country_id" | ||
|
175 | end |
|
184 | end |
|
176 |
|
185 | ||
|
177 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
186 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
178 |
|
187 | ||
|
179 | end |
|
188 | end |
You need to be logged in to leave comments.
Login now