Description:
re-added registration config
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r774:0f0c4f139f2b - - 1 file changed: 8 inserted, 0 deleted
@@ -1,267 +1,275 | |||||
|
1 | CONFIGURATIONS = |
|
1 | CONFIGURATIONS = |
|
2 | [ |
|
2 | [ |
|
3 | { |
|
3 | { |
|
4 | :key => 'system.single_user_mode', |
|
4 | :key => 'system.single_user_mode', |
|
5 | :value_type => 'boolean', |
|
5 | :value_type => 'boolean', |
|
6 | :default_value => 'false', |
|
6 | :default_value => 'false', |
|
7 | :description => 'Only admins can log in to the system when running under single user mode.' |
|
7 | :description => 'Only admins can log in to the system when running under single user mode.' |
|
8 | }, |
|
8 | }, |
|
9 |
|
9 | ||
|
10 | { |
|
10 | { |
|
11 | :key => 'ui.front.title', |
|
11 | :key => 'ui.front.title', |
|
12 | :value_type => 'string', |
|
12 | :value_type => 'string', |
|
13 | :default_value => 'Grader' |
|
13 | :default_value => 'Grader' |
|
14 | }, |
|
14 | }, |
|
15 |
|
15 | ||
|
16 | { |
|
16 | { |
|
17 | :key => 'ui.front.welcome_message', |
|
17 | :key => 'ui.front.welcome_message', |
|
18 | :value_type => 'string', |
|
18 | :value_type => 'string', |
|
19 | :default_value => 'Welcome!' |
|
19 | :default_value => 'Welcome!' |
|
20 | }, |
|
20 | }, |
|
21 |
|
21 | ||
|
22 | { |
|
22 | { |
|
23 | :key => 'ui.show_score', |
|
23 | :key => 'ui.show_score', |
|
24 | :value_type => 'boolean', |
|
24 | :value_type => 'boolean', |
|
25 | :default_value => 'true' |
|
25 | :default_value => 'true' |
|
26 | }, |
|
26 | }, |
|
27 |
|
27 | ||
|
28 | { |
|
28 | { |
|
29 | :key => 'contest.time_limit', |
|
29 | :key => 'contest.time_limit', |
|
30 | :value_type => 'string', |
|
30 | :value_type => 'string', |
|
31 | :default_value => 'unlimited', |
|
31 | :default_value => 'unlimited', |
|
32 | :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.' |
|
32 | :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.' |
|
33 | }, |
|
33 | }, |
|
34 |
|
34 | ||
|
35 | { |
|
35 | { |
|
36 | :key => 'system.mode', |
|
36 | :key => 'system.mode', |
|
37 | :value_type => 'string', |
|
37 | :value_type => 'string', |
|
38 | :default_value => 'standard', |
|
38 | :default_value => 'standard', |
|
39 | :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".' |
|
39 | :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".' |
|
40 | }, |
|
40 | }, |
|
41 |
|
41 | ||
|
42 | { |
|
42 | { |
|
43 | :key => 'contest.name', |
|
43 | :key => 'contest.name', |
|
44 | :value_type => 'string', |
|
44 | :value_type => 'string', |
|
45 | :default_value => 'Grader', |
|
45 | :default_value => 'Grader', |
|
46 | :description => 'This name will be shown on the user header bar.' |
|
46 | :description => 'This name will be shown on the user header bar.' |
|
47 | }, |
|
47 | }, |
|
48 |
|
48 | ||
|
49 | { |
|
49 | { |
|
50 | :key => 'contest.multisites', |
|
50 | :key => 'contest.multisites', |
|
51 | :value_type => 'boolean', |
|
51 | :value_type => 'boolean', |
|
52 | :default_value => 'false', |
|
52 | :default_value => 'false', |
|
53 | :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' |
|
53 | :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' |
|
54 | }, |
|
54 | }, |
|
55 |
|
55 | ||
|
56 | #---------------------------- right -------------------------------- |
|
56 | #---------------------------- right -------------------------------- |
|
57 | { |
|
57 | { |
|
58 | :key => 'right.user_hall_of_fame', |
|
58 | :key => 'right.user_hall_of_fame', |
|
59 | :value_type => 'boolean', |
|
59 | :value_type => 'boolean', |
|
60 | :default_value => 'false', |
|
60 | :default_value => 'false', |
|
61 | :description => 'If true, any user can access hall of fame page.' |
|
61 | :description => 'If true, any user can access hall of fame page.' |
|
62 | }, |
|
62 | }, |
|
63 |
|
63 | ||
|
64 | { |
|
64 | { |
|
65 | :key => 'right.multiple_ip_login', |
|
65 | :key => 'right.multiple_ip_login', |
|
66 | :value_type => 'boolean', |
|
66 | :value_type => 'boolean', |
|
67 | :default_value => 'true', |
|
67 | :default_value => 'true', |
|
68 | :description => 'When change from true to false, a user can login from the first IP they logged into afterward.' |
|
68 | :description => 'When change from true to false, a user can login from the first IP they logged into afterward.' |
|
69 | }, |
|
69 | }, |
|
70 |
|
70 | ||
|
71 | { |
|
71 | { |
|
72 | :key => 'right.user_view_submission', |
|
72 | :key => 'right.user_view_submission', |
|
73 | :value_type => 'boolean', |
|
73 | :value_type => 'boolean', |
|
74 | :default_value => 'false', |
|
74 | :default_value => 'false', |
|
75 | :description => 'If true, any user can view submissions of every one.' |
|
75 | :description => 'If true, any user can view submissions of every one.' |
|
76 | }, |
|
76 | }, |
|
77 |
|
77 | ||
|
78 | { |
|
78 | { |
|
79 | :key => 'right.bypass_agreement', |
|
79 | :key => 'right.bypass_agreement', |
|
80 | :value_type => 'boolean', |
|
80 | :value_type => 'boolean', |
|
81 | :default_value => 'true', |
|
81 | :default_value => 'true', |
|
82 | :description => 'When false, a user must accept usage agreement before login' |
|
82 | :description => 'When false, a user must accept usage agreement before login' |
|
83 | }, |
|
83 | }, |
|
84 |
|
84 | ||
|
85 | { |
|
85 | { |
|
86 | :key => 'right.heartbeat_response', |
|
86 | :key => 'right.heartbeat_response', |
|
87 | :value_type => 'string', |
|
87 | :value_type => 'string', |
|
88 | :default_value => 'OK', |
|
88 | :default_value => 'OK', |
|
89 | :description => 'Heart beat response text' |
|
89 | :description => 'Heart beat response text' |
|
90 | }, |
|
90 | }, |
|
91 |
|
91 | ||
|
92 | { |
|
92 | { |
|
93 | :key => 'right.heartbeat_response_full', |
|
93 | :key => 'right.heartbeat_response_full', |
|
94 | :value_type => 'string', |
|
94 | :value_type => 'string', |
|
95 | :default_value => 'OK', |
|
95 | :default_value => 'OK', |
|
96 | :description => 'Heart beat response text when user got full score (set this value to the empty string to disable this feature)' |
|
96 | :description => 'Heart beat response text when user got full score (set this value to the empty string to disable this feature)' |
|
97 | }, |
|
97 | }, |
|
98 |
|
98 | ||
|
99 | { |
|
99 | { |
|
100 | :key => 'right.view_testcase', |
|
100 | :key => 'right.view_testcase', |
|
101 | :value_type => 'boolean', |
|
101 | :value_type => 'boolean', |
|
102 | :default_value => 'false', |
|
102 | :default_value => 'false', |
|
103 | :description => 'When true, any user can view/download test data' |
|
103 | :description => 'When true, any user can view/download test data' |
|
104 | }, |
|
104 | }, |
|
|
105 | + | ||
|
|
106 | + { | ||
|
|
107 | + :key => 'system.online_registration', | ||
|
|
108 | + :value_type => 'boolean', | ||
|
|
109 | + :default_value => 'false', | ||
|
|
110 | + :description => 'This option enables online registration.' | ||
|
|
111 | + }, | ||
|
|
112 | + | ||
|
105 | # If Configuration['system.online_registration'] is true, the |
|
113 | # If Configuration['system.online_registration'] is true, the |
|
106 | # system allows online registration, and will use these |
|
114 | # system allows online registration, and will use these |
|
107 | # information for sending confirmation emails. |
|
115 | # information for sending confirmation emails. |
|
108 | { |
|
116 | { |
|
109 | :key => 'system.online_registration.smtp', |
|
117 | :key => 'system.online_registration.smtp', |
|
110 | :value_type => 'string', |
|
118 | :value_type => 'string', |
|
111 | :default_value => 'smtp.somehost.com' |
|
119 | :default_value => 'smtp.somehost.com' |
|
112 | }, |
|
120 | }, |
|
113 |
|
121 | ||
|
114 | { |
|
122 | { |
|
115 | :key => 'system.online_registration.from', |
|
123 | :key => 'system.online_registration.from', |
|
116 | :value_type => 'string', |
|
124 | :value_type => 'string', |
|
117 | :default_value => 'your.email@address' |
|
125 | :default_value => 'your.email@address' |
|
118 | }, |
|
126 | }, |
|
119 |
|
127 | ||
|
120 | { |
|
128 | { |
|
121 | :key => 'system.admin_email', |
|
129 | :key => 'system.admin_email', |
|
122 | :value_type => 'string', |
|
130 | :value_type => 'string', |
|
123 | :default_value => 'admin@admin.email' |
|
131 | :default_value => 'admin@admin.email' |
|
124 | }, |
|
132 | }, |
|
125 |
|
133 | ||
|
126 | { |
|
134 | { |
|
127 | :key => 'system.user_setting_enabled', |
|
135 | :key => 'system.user_setting_enabled', |
|
128 | :value_type => 'boolean', |
|
136 | :value_type => 'boolean', |
|
129 | :default_value => 'true', |
|
137 | :default_value => 'true', |
|
130 | :description => 'If this option is true, users can change their settings' |
|
138 | :description => 'If this option is true, users can change their settings' |
|
131 | }, |
|
139 | }, |
|
132 |
|
140 | ||
|
133 | { |
|
141 | { |
|
134 | :key => 'system.user_setting_enabled', |
|
142 | :key => 'system.user_setting_enabled', |
|
135 | :value_type => 'boolean', |
|
143 | :value_type => 'boolean', |
|
136 | :default_value => 'true', |
|
144 | :default_value => 'true', |
|
137 | :description => 'If this option is true, users can change their settings' |
|
145 | :description => 'If this option is true, users can change their settings' |
|
138 | }, |
|
146 | }, |
|
139 |
|
147 | ||
|
140 | # If Configuration['contest.test_request.early_timeout'] is true |
|
148 | # If Configuration['contest.test_request.early_timeout'] is true |
|
141 | # the user will not be able to use test request at 30 minutes |
|
149 | # the user will not be able to use test request at 30 minutes |
|
142 | # before the contest ends. |
|
150 | # before the contest ends. |
|
143 | { |
|
151 | { |
|
144 | :key => 'contest.test_request.early_timeout', |
|
152 | :key => 'contest.test_request.early_timeout', |
|
145 | :value_type => 'boolean', |
|
153 | :value_type => 'boolean', |
|
146 | :default_value => 'false' |
|
154 | :default_value => 'false' |
|
147 | }, |
|
155 | }, |
|
148 |
|
156 | ||
|
149 | { |
|
157 | { |
|
150 | :key => 'system.multicontests', |
|
158 | :key => 'system.multicontests', |
|
151 | :value_type => 'boolean', |
|
159 | :value_type => 'boolean', |
|
152 | :default_value => 'false' |
|
160 | :default_value => 'false' |
|
153 | }, |
|
161 | }, |
|
154 |
|
162 | ||
|
155 | { |
|
163 | { |
|
156 | :key => 'contest.confirm_indv_contest_start', |
|
164 | :key => 'contest.confirm_indv_contest_start', |
|
157 | :value_type => 'boolean', |
|
165 | :value_type => 'boolean', |
|
158 | :default_value => 'false' |
|
166 | :default_value => 'false' |
|
159 | }, |
|
167 | }, |
|
160 |
|
168 | ||
|
161 | { |
|
169 | { |
|
162 | :key => 'contest.default_contest_name', |
|
170 | :key => 'contest.default_contest_name', |
|
163 | :value_type => 'string', |
|
171 | :value_type => 'string', |
|
164 | :default_value => 'none', |
|
172 | :default_value => 'none', |
|
165 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
173 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
166 | }, |
|
174 | }, |
|
167 |
|
175 | ||
|
168 | { |
|
176 | { |
|
169 | :key => 'system.use_problem_group', |
|
177 | :key => 'system.use_problem_group', |
|
170 | :value_type => 'boolean', |
|
178 | :value_type => 'boolean', |
|
171 | :default_value => 'false', |
|
179 | :default_value => 'false', |
|
172 | :description => "If true, available problem to the user will be only ones associated with the group of the user." |
|
180 | :description => "If true, available problem to the user will be only ones associated with the group of the user." |
|
173 | }, |
|
181 | }, |
|
174 |
|
182 | ||
|
175 |
|
183 | ||
|
176 |
|
184 | ||
|
177 | ] |
|
185 | ] |
|
178 |
|
186 | ||
|
179 |
|
187 | ||
|
180 | def create_configuration_key(key, |
|
188 | def create_configuration_key(key, |
|
181 | value_type, |
|
189 | value_type, |
|
182 | default_value, |
|
190 | default_value, |
|
183 | description='') |
|
191 | description='') |
|
184 | conf = (GraderConfiguration.find_by_key(key) || |
|
192 | conf = (GraderConfiguration.find_by_key(key) || |
|
185 | GraderConfiguration.new(:key => key, |
|
193 | GraderConfiguration.new(:key => key, |
|
186 | :value_type => value_type, |
|
194 | :value_type => value_type, |
|
187 | :value => default_value)) |
|
195 | :value => default_value)) |
|
188 | conf.description = description |
|
196 | conf.description = description |
|
189 | conf.save |
|
197 | conf.save |
|
190 | end |
|
198 | end |
|
191 |
|
199 | ||
|
192 | def seed_config |
|
200 | def seed_config |
|
193 | CONFIGURATIONS.each do |conf| |
|
201 | CONFIGURATIONS.each do |conf| |
|
194 | if conf.has_key? :description |
|
202 | if conf.has_key? :description |
|
195 | desc = conf[:description] |
|
203 | desc = conf[:description] |
|
196 | else |
|
204 | else |
|
197 | desc = '' |
|
205 | desc = '' |
|
198 | end |
|
206 | end |
|
199 | create_configuration_key(conf[:key], |
|
207 | create_configuration_key(conf[:key], |
|
200 | conf[:value_type], |
|
208 | conf[:value_type], |
|
201 | conf[:default_value], |
|
209 | conf[:default_value], |
|
202 | desc) |
|
210 | desc) |
|
203 | end |
|
211 | end |
|
204 | end |
|
212 | end |
|
205 |
|
213 | ||
|
206 | def seed_roles |
|
214 | def seed_roles |
|
207 | return if Role.find_by_name('admin') |
|
215 | return if Role.find_by_name('admin') |
|
208 |
|
216 | ||
|
209 | role = Role.create(:name => 'admin') |
|
217 | role = Role.create(:name => 'admin') |
|
210 | user_admin_right = Right.create(:name => 'user_admin', |
|
218 | user_admin_right = Right.create(:name => 'user_admin', |
|
211 | :controller => 'user_admin', |
|
219 | :controller => 'user_admin', |
|
212 | :action => 'all') |
|
220 | :action => 'all') |
|
213 | problem_admin_right = Right.create(:name=> 'problem_admin', |
|
221 | problem_admin_right = Right.create(:name=> 'problem_admin', |
|
214 | :controller => 'problems', |
|
222 | :controller => 'problems', |
|
215 | :action => 'all') |
|
223 | :action => 'all') |
|
216 |
|
224 | ||
|
217 | graders_right = Right.create(:name => 'graders_admin', |
|
225 | graders_right = Right.create(:name => 'graders_admin', |
|
218 | :controller => 'graders', |
|
226 | :controller => 'graders', |
|
219 | :action => 'all') |
|
227 | :action => 'all') |
|
220 |
|
228 | ||
|
221 | role.rights << user_admin_right; |
|
229 | role.rights << user_admin_right; |
|
222 | role.rights << problem_admin_right; |
|
230 | role.rights << problem_admin_right; |
|
223 | role.rights << graders_right; |
|
231 | role.rights << graders_right; |
|
224 | role.save |
|
232 | role.save |
|
225 | end |
|
233 | end |
|
226 |
|
234 | ||
|
227 | def seed_root |
|
235 | def seed_root |
|
228 | return if User.find_by_login('root') |
|
236 | return if User.find_by_login('root') |
|
229 |
|
237 | ||
|
230 | root = User.new(:login => 'root', |
|
238 | root = User.new(:login => 'root', |
|
231 | :full_name => 'Administrator', |
|
239 | :full_name => 'Administrator', |
|
232 | :alias => 'root') |
|
240 | :alias => 'root') |
|
233 | root.password = 'ioionrails'; |
|
241 | root.password = 'ioionrails'; |
|
234 |
|
242 | ||
|
235 | class << root |
|
243 | class << root |
|
236 | public :encrypt_new_password |
|
244 | public :encrypt_new_password |
|
237 | def valid?(context=nil) |
|
245 | def valid?(context=nil) |
|
238 | true |
|
246 | true |
|
239 | end |
|
247 | end |
|
240 | end |
|
248 | end |
|
241 |
|
249 | ||
|
242 | root.encrypt_new_password |
|
250 | root.encrypt_new_password |
|
243 |
|
251 | ||
|
244 | root.roles << Role.find_by_name('admin') |
|
252 | root.roles << Role.find_by_name('admin') |
|
245 |
|
253 | ||
|
246 | root.activated = true |
|
254 | root.activated = true |
|
247 | root.save |
|
255 | root.save |
|
248 | end |
|
256 | end |
|
249 |
|
257 | ||
|
250 | def seed_users_and_roles |
|
258 | def seed_users_and_roles |
|
251 | seed_roles |
|
259 | seed_roles |
|
252 | seed_root |
|
260 | seed_root |
|
253 | end |
|
261 | end |
|
254 |
|
262 | ||
|
255 | def seed_more_languages |
|
263 | def seed_more_languages |
|
256 | Language.delete_all |
|
264 | Language.delete_all |
|
257 | Language.create( name: 'c', pretty_name: 'C', ext: 'c', common_ext: 'c' ) |
|
265 | Language.create( name: 'c', pretty_name: 'C', ext: 'c', common_ext: 'c' ) |
|
258 | Language.create( name: 'cpp', pretty_name: 'C++', ext: 'cpp', common_ext: 'cpp,cc' ) |
|
266 | Language.create( name: 'cpp', pretty_name: 'C++', ext: 'cpp', common_ext: 'cpp,cc' ) |
|
259 | Language.create( name: 'pas', pretty_name: 'Pascal', ext: 'pas', common_ext: 'pas' ) |
|
267 | Language.create( name: 'pas', pretty_name: 'Pascal', ext: 'pas', common_ext: 'pas' ) |
|
260 | Language.create( name: 'ruby', pretty_name: 'Ruby', ext: 'rb', common_ext: 'rb' ) |
|
268 | Language.create( name: 'ruby', pretty_name: 'Ruby', ext: 'rb', common_ext: 'rb' ) |
|
261 | Language.create( name: 'python', pretty_name: 'Python', ext: 'py', common_ext: 'py' ) |
|
269 | Language.create( name: 'python', pretty_name: 'Python', ext: 'py', common_ext: 'py' ) |
|
262 | Language.create( name: 'java', pretty_name: 'Java', ext: 'java', common_ext: 'java' ) |
|
270 | Language.create( name: 'java', pretty_name: 'Java', ext: 'java', common_ext: 'java' ) |
|
263 | end |
|
271 | end |
|
264 |
|
272 | ||
|
265 | seed_config |
|
273 | seed_config |
|
266 | seed_users_and_roles |
|
274 | seed_users_and_roles |
|
267 | seed_more_languages |
|
275 | seed_more_languages |
You need to be logged in to leave comments.
Login now