Description:
add license agreement checkbox
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r535:a0fe4acdb4ed - - 3 files changed: 10 inserted, 2 deleted

@@ -1,54 +1,57
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 def index
3 def index
4 # show login screen
4 # show login screen
5 reset_session
5 reset_session
6 redirect_to :controller => 'main', :action => 'login'
6 redirect_to :controller => 'main', :action => 'login'
7 end
7 end
8
8
9 def login
9 def login
10 - if user = User.authenticate(params[:login], params[:password])
10 + if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree])
11 + flash[:notice] = 'You must accept the agreement before logging in'
12 + redirect_to :controller => 'main', :action => 'login'
13 + elsif user = User.authenticate(params[:login], params[:password])
11 session[:user_id] = user.id
14 session[:user_id] = user.id
12 session[:admin] = user.admin?
15 session[:admin] = user.admin?
13
16
14 # clear forced logout flag for multicontests contest change
17 # clear forced logout flag for multicontests contest change
15 if GraderConfiguration.multicontests?
18 if GraderConfiguration.multicontests?
16 contest_stat = user.contest_stat
19 contest_stat = user.contest_stat
17 if contest_stat.respond_to? :forced_logout
20 if contest_stat.respond_to? :forced_logout
18 if contest_stat.forced_logout
21 if contest_stat.forced_logout
19 contest_stat.forced_logout = false
22 contest_stat.forced_logout = false
20 contest_stat.save
23 contest_stat.save
21 end
24 end
22 end
25 end
23 end
26 end
24
27
25 #save login information
28 #save login information
26 Login.create(user_id: user.id, ip_address: request.remote_ip)
29 Login.create(user_id: user.id, ip_address: request.remote_ip)
27
30
28 redirect_to :controller => 'main', :action => 'list'
31 redirect_to :controller => 'main', :action => 'list'
29 else
32 else
30 flash[:notice] = 'Wrong password'
33 flash[:notice] = 'Wrong password'
31 redirect_to :controller => 'main', :action => 'login'
34 redirect_to :controller => 'main', :action => 'login'
32 end
35 end
33 end
36 end
34
37
35 def site_login
38 def site_login
36 begin
39 begin
37 site = Site.find(params[:login][:site_id])
40 site = Site.find(params[:login][:site_id])
38 rescue ActiveRecord::RecordNotFound
41 rescue ActiveRecord::RecordNotFound
39 site = nil
42 site = nil
40 end
43 end
41 if site==nil
44 if site==nil
42 flash[:notice] = 'Wrong site'
45 flash[:notice] = 'Wrong site'
43 redirect_to :controller => 'main', :action => 'login' and return
46 redirect_to :controller => 'main', :action => 'login' and return
44 end
47 end
45 if (site.password) and (site.password == params[:login][:password])
48 if (site.password) and (site.password == params[:login][:password])
46 session[:site_id] = site.id
49 session[:site_id] = site.id
47 redirect_to :controller => 'site', :action => 'index'
50 redirect_to :controller => 'site', :action => 'index'
48 else
51 else
49 flash[:notice] = 'Wrong site password'
52 flash[:notice] = 'Wrong site password'
50 redirect_to :controller => 'site', :action => 'login'
53 redirect_to :controller => 'site', :action => 'login'
51 end
54 end
52 end
55 end
53
56
54 end
57 end
@@ -1,34 +1,39
1 %b= GraderConfiguration['ui.front.welcome_message']
1 %b= GraderConfiguration['ui.front.welcome_message']
2 %br/
2 %br/
3
3
4 - if !@hidelogin
4 - if !@hidelogin
5 =t 'login.message'
5 =t 'login.message'
6 %br/
6 %br/
7 %br/
7 %br/
8
8
9 - if flash[:notice]
9 - if flash[:notice]
10 %hr/
10 %hr/
11 %b= flash[:notice]
11 %b= flash[:notice]
12 %hr/
12 %hr/
13
13
14 %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
14 %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
15 = form_tag :controller => 'login', :action => 'login' do
15 = form_tag :controller => 'login', :action => 'login' do
16 %table
16 %table
17 %tr
17 %tr
18 %td{:align => "right"}
18 %td{:align => "right"}
19 ="#{t 'login_label'}:"
19 ="#{t 'login_label'}:"
20 %td= text_field_tag 'login'
20 %td= text_field_tag 'login'
21 %tr
21 %tr
22 %td{:align => "right"}
22 %td{:align => "right"}
23 ="#{t 'password_label'}:"
23 ="#{t 'password_label'}:"
24 %td= password_field_tag
24 %td= password_field_tag
25 + - unless GraderConfiguration['right.bypass_agreement']
26 + %tr
27 + %td{:align => "right"}= check_box_tag 'accept_agree'
28 + %td ΰΈ’ΰΈ­ΰΈ‘ΰΈ£ΰΈ±ΰΈšΰΈ‚ΰΉ‰ΰΈ­ΰΈ•ΰΈΰΈ₯ΰΈ‡ΰΈΰΈ²ΰΈ£ΰΉƒΰΈŠΰΉ‰ΰΈ‡ΰΈ²ΰΈ™
29 +
25 = submit_tag t('login.login_submit')
30 = submit_tag t('login.login_submit')
26 %br/
31 %br/
27
32
28 - if GraderConfiguration['system.online_registration']
33 - if GraderConfiguration['system.online_registration']
29 =t 'login.participation'
34 =t 'login.participation'
30 %b
35 %b
31 = "#{t 'login.please'} "
36 = "#{t 'login.please'} "
32 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
37 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
33 %br/
38 %br/
34 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
39 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
@@ -1,206 +1,206
1 # encoding: UTF-8
1 # encoding: UTF-8
2 # This file is auto-generated from the current state of the database. Instead
2 # This file is auto-generated from the current state of the database. Instead
3 # of editing this file, please use the migrations feature of Active Record to
3 # of editing this file, please use the migrations feature of Active Record to
4 # incrementally modify your database, and then regenerate this schema definition.
4 # incrementally modify your database, and then regenerate this schema definition.
5 #
5 #
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 # It's strongly recommended to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(:version => 20150914155101) do
14 + ActiveRecord::Schema.define(:version => 20150914223258) do
15
15
16 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
17 t.string "author"
17 t.string "author"
18 t.text "body", :limit => 16777215
18 t.text "body", :limit => 16777215
19 t.boolean "published"
19 t.boolean "published"
20 t.datetime "created_at", :null => false
20 t.datetime "created_at", :null => false
21 t.datetime "updated_at", :null => false
21 t.datetime "updated_at", :null => false
22 t.boolean "frontpage", :default => false
22 t.boolean "frontpage", :default => false
23 t.boolean "contest_only", :default => false
23 t.boolean "contest_only", :default => false
24 t.string "title"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 create_table "contests", :force => true do |t|
28 create_table "contests", :force => true do |t|
29 t.string "title"
29 t.string "title"
30 t.boolean "enabled"
30 t.boolean "enabled"
31 t.datetime "created_at", :null => false
31 t.datetime "created_at", :null => false
32 t.datetime "updated_at", :null => false
32 t.datetime "updated_at", :null => false
33 t.string "name"
33 t.string "name"
34 end
34 end
35
35
36 create_table "contests_problems", :id => false, :force => true do |t|
36 create_table "contests_problems", :id => false, :force => true do |t|
37 t.integer "contest_id"
37 t.integer "contest_id"
38 t.integer "problem_id"
38 t.integer "problem_id"
39 end
39 end
40
40
41 create_table "contests_users", :id => false, :force => true do |t|
41 create_table "contests_users", :id => false, :force => true do |t|
42 t.integer "contest_id"
42 t.integer "contest_id"
43 t.integer "user_id"
43 t.integer "user_id"
44 end
44 end
45
45
46 create_table "countries", :force => true do |t|
46 create_table "countries", :force => true do |t|
47 t.string "name"
47 t.string "name"
48 t.datetime "created_at", :null => false
48 t.datetime "created_at", :null => false
49 t.datetime "updated_at", :null => false
49 t.datetime "updated_at", :null => false
50 end
50 end
51
51
52 create_table "descriptions", :force => true do |t|
52 create_table "descriptions", :force => true do |t|
53 t.text "body", :limit => 16777215
53 t.text "body", :limit => 16777215
54 t.boolean "markdowned"
54 t.boolean "markdowned"
55 t.datetime "created_at", :null => false
55 t.datetime "created_at", :null => false
56 t.datetime "updated_at", :null => false
56 t.datetime "updated_at", :null => false
57 end
57 end
58
58
59 create_table "grader_configurations", :force => true do |t|
59 create_table "grader_configurations", :force => true do |t|
60 t.string "key"
60 t.string "key"
61 t.string "value_type"
61 t.string "value_type"
62 t.string "value"
62 t.string "value"
63 t.datetime "created_at", :null => false
63 t.datetime "created_at", :null => false
64 t.datetime "updated_at", :null => false
64 t.datetime "updated_at", :null => false
65 t.text "description", :limit => 16777215
65 t.text "description", :limit => 16777215
66 end
66 end
67
67
68 create_table "grader_processes", :force => true do |t|
68 create_table "grader_processes", :force => true do |t|
69 t.string "host", :limit => 20
69 t.string "host", :limit => 20
70 t.integer "pid"
70 t.integer "pid"
71 t.string "mode"
71 t.string "mode"
72 t.boolean "active"
72 t.boolean "active"
73 t.datetime "created_at", :null => false
73 t.datetime "created_at", :null => false
74 t.datetime "updated_at", :null => false
74 t.datetime "updated_at", :null => false
75 t.integer "task_id"
75 t.integer "task_id"
76 t.string "task_type"
76 t.string "task_type"
77 t.boolean "terminated"
77 t.boolean "terminated"
78 end
78 end
79
79
80 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
80 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
81
81
82 create_table "heart_beats", :force => true do |t|
82 create_table "heart_beats", :force => true do |t|
83 t.integer "user_id"
83 t.integer "user_id"
84 t.string "ip_address"
84 t.string "ip_address"
85 t.datetime "created_at", :null => false
85 t.datetime "created_at", :null => false
86 t.datetime "updated_at", :null => false
86 t.datetime "updated_at", :null => false
87 t.string "status"
87 t.string "status"
88 end
88 end
89
89
90 create_table "languages", :force => true do |t|
90 create_table "languages", :force => true do |t|
91 t.string "name", :limit => 10
91 t.string "name", :limit => 10
92 t.string "pretty_name"
92 t.string "pretty_name"
93 t.string "ext", :limit => 10
93 t.string "ext", :limit => 10
94 t.string "common_ext"
94 t.string "common_ext"
95 end
95 end
96
96
97 create_table "logins", :force => true do |t|
97 create_table "logins", :force => true do |t|
98 t.integer "user_id"
98 t.integer "user_id"
99 t.string "ip_address"
99 t.string "ip_address"
100 t.datetime "created_at", :null => false
100 t.datetime "created_at", :null => false
101 t.datetime "updated_at", :null => false
101 t.datetime "updated_at", :null => false
102 end
102 end
103
103
104 create_table "messages", :force => true do |t|
104 create_table "messages", :force => true do |t|
105 t.integer "sender_id"
105 t.integer "sender_id"
106 t.integer "receiver_id"
106 t.integer "receiver_id"
107 t.integer "replying_message_id"
107 t.integer "replying_message_id"
108 t.text "body", :limit => 16777215
108 t.text "body", :limit => 16777215
109 t.boolean "replied"
109 t.boolean "replied"
110 t.datetime "created_at", :null => false
110 t.datetime "created_at", :null => false
111 t.datetime "updated_at", :null => false
111 t.datetime "updated_at", :null => false
112 end
112 end
113
113
114 create_table "problems", :force => true do |t|
114 create_table "problems", :force => true do |t|
115 t.string "name", :limit => 30
115 t.string "name", :limit => 30
116 t.string "full_name"
116 t.string "full_name"
117 t.integer "full_score"
117 t.integer "full_score"
118 t.date "date_added"
118 t.date "date_added"
119 t.boolean "available"
119 t.boolean "available"
120 t.string "url"
120 t.string "url"
121 t.integer "description_id"
121 t.integer "description_id"
122 t.boolean "test_allowed"
122 t.boolean "test_allowed"
123 t.boolean "output_only"
123 t.boolean "output_only"
124 t.string "description_filename"
124 t.string "description_filename"
125 end
125 end
126
126
127 create_table "rights", :force => true do |t|
127 create_table "rights", :force => true do |t|
128 t.string "name"
128 t.string "name"
129 t.string "controller"
129 t.string "controller"
130 t.string "action"
130 t.string "action"
131 end
131 end
132
132
133 create_table "rights_roles", :id => false, :force => true do |t|
133 create_table "rights_roles", :id => false, :force => true do |t|
134 t.integer "right_id"
134 t.integer "right_id"
135 t.integer "role_id"
135 t.integer "role_id"
136 end
136 end
137
137
138 add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
138 add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
139
139
140 create_table "roles", :force => true do |t|
140 create_table "roles", :force => true do |t|
141 t.string "name"
141 t.string "name"
142 end
142 end
143
143
144 create_table "roles_users", :id => false, :force => true do |t|
144 create_table "roles_users", :id => false, :force => true do |t|
145 t.integer "role_id"
145 t.integer "role_id"
146 t.integer "user_id"
146 t.integer "user_id"
147 end
147 end
148
148
149 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
149 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
150
150
151 create_table "sessions", :force => true do |t|
151 create_table "sessions", :force => true do |t|
152 t.string "session_id"
152 t.string "session_id"
153 t.text "data", :limit => 16777215
153 t.text "data", :limit => 16777215
154 t.datetime "updated_at"
154 t.datetime "updated_at"
155 end
155 end
156
156
157 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
157 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
158 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
158 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
159
159
160 create_table "sites", :force => true do |t|
160 create_table "sites", :force => true do |t|
161 t.string "name"
161 t.string "name"
162 t.boolean "started"
162 t.boolean "started"
163 t.datetime "start_time"
163 t.datetime "start_time"
164 t.datetime "created_at", :null => false
164 t.datetime "created_at", :null => false
165 t.datetime "updated_at", :null => false
165 t.datetime "updated_at", :null => false
166 t.integer "country_id"
166 t.integer "country_id"
167 t.string "password"
167 t.string "password"
168 end
168 end
169
169
170 create_table "submission_view_logs", :force => true do |t|
170 create_table "submission_view_logs", :force => true do |t|
171 t.integer "user_id"
171 t.integer "user_id"
172 t.integer "submission_id"
172 t.integer "submission_id"
173 t.datetime "created_at", :null => false
173 t.datetime "created_at", :null => false
174 t.datetime "updated_at", :null => false
174 t.datetime "updated_at", :null => false
175 end
175 end
176
176
177 create_table "submissions", :force => true do |t|
177 create_table "submissions", :force => true do |t|
178 t.integer "user_id"
178 t.integer "user_id"
179 t.integer "problem_id"
179 t.integer "problem_id"
180 t.integer "language_id"
180 t.integer "language_id"
181 t.text "source", :limit => 16777215
181 t.text "source", :limit => 16777215
182 t.binary "binary"
182 t.binary "binary"
183 t.datetime "submitted_at"
183 t.datetime "submitted_at"
184 t.datetime "compiled_at"
184 t.datetime "compiled_at"
185 t.text "compiler_message", :limit => 16777215
185 t.text "compiler_message", :limit => 16777215
186 t.datetime "graded_at"
186 t.datetime "graded_at"
187 t.integer "points"
187 t.integer "points"
188 t.text "grader_comment", :limit => 16777215
188 t.text "grader_comment", :limit => 16777215
189 t.integer "number"
189 t.integer "number"
190 t.string "source_filename"
190 t.string "source_filename"
191 t.float "max_runtime"
191 t.float "max_runtime"
192 t.integer "peak_memory"
192 t.integer "peak_memory"
193 t.integer "effective_code_length"
193 t.integer "effective_code_length"
194 t.string "ip_address"
194 t.string "ip_address"
195 end
195 end
196
196
197 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
197 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
198 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
198 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
199
199
200 create_table "tasks", :force => true do |t|
200 create_table "tasks", :force => true do |t|
201 t.integer "submission_id"
201 t.integer "submission_id"
202 t.datetime "created_at"
202 t.datetime "created_at"
203 t.integer "status"
203 t.integer "status"
204 t.datetime "updated_at"
204 t.datetime "updated_at"
205 end
205 end
206
206
You need to be logged in to leave comments. Login now