Description:
merge with syntax highlighter
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r421:c902a510d4ef - - 1 file changed: 11 inserted, 0 deleted

@@ -5,194 +5,205
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 {
56 {
57 :key => 'system.online_registration',
57 :key => 'system.online_registration',
58 :value_type => 'boolean',
58 :value_type => 'boolean',
59 :default_value => 'false',
59 :default_value => 'false',
60 :description => 'This option enables online registration.'
60 :description => 'This option enables online registration.'
61 },
61 },
62
62
63 # If Configuration['system.online_registration'] is true, the
63 # If Configuration['system.online_registration'] is true, the
64 # system allows online registration, and will use these
64 # system allows online registration, and will use these
65 # information for sending confirmation emails.
65 # information for sending confirmation emails.
66 {
66 {
67 :key => 'system.online_registration.smtp',
67 :key => 'system.online_registration.smtp',
68 :value_type => 'string',
68 :value_type => 'string',
69 :default_value => 'smtp.somehost.com'
69 :default_value => 'smtp.somehost.com'
70 },
70 },
71
71
72 {
72 {
73 :key => 'system.online_registration.from',
73 :key => 'system.online_registration.from',
74 :value_type => 'string',
74 :value_type => 'string',
75 :default_value => 'your.email@address'
75 :default_value => 'your.email@address'
76 },
76 },
77
77
78 {
78 {
79 :key => 'system.admin_email',
79 :key => 'system.admin_email',
80 :value_type => 'string',
80 :value_type => 'string',
81 :default_value => 'admin@admin.email'
81 :default_value => 'admin@admin.email'
82 },
82 },
83
83
84 {
84 {
85 :key => 'system.user_setting_enabled',
85 :key => 'system.user_setting_enabled',
86 :value_type => 'boolean',
86 :value_type => 'boolean',
87 :default_value => 'true',
87 :default_value => 'true',
88 :description => 'If this option is true, users can change their settings'
88 :description => 'If this option is true, users can change their settings'
89 },
89 },
90
90
91 # If Configuration['contest.test_request.early_timeout'] is true
91 # If Configuration['contest.test_request.early_timeout'] is true
92 # the user will not be able to use test request at 30 minutes
92 # the user will not be able to use test request at 30 minutes
93 # before the contest ends.
93 # before the contest ends.
94 {
94 {
95 :key => 'contest.test_request.early_timeout',
95 :key => 'contest.test_request.early_timeout',
96 :value_type => 'boolean',
96 :value_type => 'boolean',
97 :default_value => 'false'
97 :default_value => 'false'
98 },
98 },
99
99
100 {
100 {
101 :key => 'system.multicontests',
101 :key => 'system.multicontests',
102 :value_type => 'boolean',
102 :value_type => 'boolean',
103 :default_value => 'false'
103 :default_value => 'false'
104 },
104 },
105
105
106 {
106 {
107 :key => 'contest.confirm_indv_contest_start',
107 :key => 'contest.confirm_indv_contest_start',
108 :value_type => 'boolean',
108 :value_type => 'boolean',
109 :default_value => 'false'
109 :default_value => 'false'
110 },
110 },
111
111
112 {
112 {
113 :key => 'contest.default_contest_name',
113 :key => 'contest.default_contest_name',
114 :value_type => 'string',
114 :value_type => 'string',
115 :default_value => 'none',
115 :default_value => 'none',
116 :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest."
116 :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest."
117 }
117 }
118
118
119 ]
119 ]
120
120
121
121
122 def create_configuration_key(key,
122 def create_configuration_key(key,
123 value_type,
123 value_type,
124 default_value,
124 default_value,
125 description='')
125 description='')
126 conf = (GraderConfiguration.find_by_key(key) ||
126 conf = (GraderConfiguration.find_by_key(key) ||
127 GraderConfiguration.new(:key => key,
127 GraderConfiguration.new(:key => key,
128 :value_type => value_type,
128 :value_type => value_type,
129 :value => default_value))
129 :value => default_value))
130 conf.description = description
130 conf.description = description
131 conf.save
131 conf.save
132 end
132 end
133
133
134 def seed_config
134 def seed_config
135 CONFIGURATIONS.each do |conf|
135 CONFIGURATIONS.each do |conf|
136 if conf.has_key? :description
136 if conf.has_key? :description
137 desc = conf[:description]
137 desc = conf[:description]
138 else
138 else
139 desc = ''
139 desc = ''
140 end
140 end
141 create_configuration_key(conf[:key],
141 create_configuration_key(conf[:key],
142 conf[:value_type],
142 conf[:value_type],
143 conf[:default_value],
143 conf[:default_value],
144 desc)
144 desc)
145 end
145 end
146 end
146 end
147
147
148 def seed_roles
148 def seed_roles
149 return if Role.find_by_name('admin')
149 return if Role.find_by_name('admin')
150
150
151 role = Role.create(:name => 'admin')
151 role = Role.create(:name => 'admin')
152 user_admin_right = Right.create(:name => 'user_admin',
152 user_admin_right = Right.create(:name => 'user_admin',
153 :controller => 'user_admin',
153 :controller => 'user_admin',
154 :action => 'all')
154 :action => 'all')
155 problem_admin_right = Right.create(:name=> 'problem_admin',
155 problem_admin_right = Right.create(:name=> 'problem_admin',
156 :controller => 'problems',
156 :controller => 'problems',
157 :action => 'all')
157 :action => 'all')
158
158
159 graders_right = Right.create(:name => 'graders_admin',
159 graders_right = Right.create(:name => 'graders_admin',
160 :controller => 'graders',
160 :controller => 'graders',
161 :action => 'all')
161 :action => 'all')
162
162
163 role.rights << user_admin_right;
163 role.rights << user_admin_right;
164 role.rights << problem_admin_right;
164 role.rights << problem_admin_right;
165 role.rights << graders_right;
165 role.rights << graders_right;
166 role.save
166 role.save
167 end
167 end
168
168
169 def seed_root
169 def seed_root
170 return if User.find_by_login('root')
170 return if User.find_by_login('root')
171
171
172 root = User.new(:login => 'root',
172 root = User.new(:login => 'root',
173 :full_name => 'Administrator',
173 :full_name => 'Administrator',
174 :alias => 'root')
174 :alias => 'root')
175 root.password = 'ioionrails';
175 root.password = 'ioionrails';
176
176
177 class << root
177 class << root
178 public :encrypt_new_password
178 public :encrypt_new_password
179 def valid?(context=nil)
179 def valid?(context=nil)
180 true
180 true
181 end
181 end
182 end
182 end
183
183
184 root.encrypt_new_password
184 root.encrypt_new_password
185
185
186 root.roles << Role.find_by_name('admin')
186 root.roles << Role.find_by_name('admin')
187
187
188 root.activated = true
188 root.activated = true
189 root.save
189 root.save
190 end
190 end
191
191
192 def seed_users_and_roles
192 def seed_users_and_roles
193 seed_roles
193 seed_roles
194 seed_root
194 seed_root
195 end
195 end
196
196
197 + def seed_more_languages
198 + Language.delete_all
199 + Language.create( name: 'c', pretty_name: 'C', ext: 'c', common_ext: 'c' )
200 + Language.create( name: 'cpp', pretty_name: 'C++', ext: 'cpp', common_ext: 'cpp,cc' )
201 + Language.create( name: 'pas', pretty_name: 'Pascal', ext: 'pas', common_ext: 'pas' )
202 + Language.create( name: 'ruby', pretty_name: 'Ruby', ext: 'rb', common_ext: 'rb' )
203 + Language.create( name: 'python', pretty_name: 'Python', ext: 'py', common_ext: 'py' )
204 + Language.create( name: 'java', pretty_name: 'Java', ext: 'java', common_ext: 'java' )
205 + end
206 +
197 seed_config
207 seed_config
198 seed_users_and_roles
208 seed_users_and_roles
209 + seed_more_languages
You need to be logged in to leave comments. Login now