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

@@ -1,198 +1,209
1 1 CONFIGURATIONS =
2 2 [
3 3 {
4 4 :key => 'system.single_user_mode',
5 5 :value_type => 'boolean',
6 6 :default_value => 'false',
7 7 :description => 'Only admins can log in to the system when running under single user mode.'
8 8 },
9 9
10 10 {
11 11 :key => 'ui.front.title',
12 12 :value_type => 'string',
13 13 :default_value => 'Grader'
14 14 },
15 15
16 16 {
17 17 :key => 'ui.front.welcome_message',
18 18 :value_type => 'string',
19 19 :default_value => 'Welcome!'
20 20 },
21 21
22 22 {
23 23 :key => 'ui.show_score',
24 24 :value_type => 'boolean',
25 25 :default_value => 'true'
26 26 },
27 27
28 28 {
29 29 :key => 'contest.time_limit',
30 30 :value_type => 'string',
31 31 :default_value => 'unlimited',
32 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 36 :key => 'system.mode',
37 37 :value_type => 'string',
38 38 :default_value => 'standard',
39 39 :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".'
40 40 },
41 41
42 42 {
43 43 :key => 'contest.name',
44 44 :value_type => 'string',
45 45 :default_value => 'Grader',
46 46 :description => 'This name will be shown on the user header bar.'
47 47 },
48 48
49 49 {
50 50 :key => 'contest.multisites',
51 51 :value_type => 'boolean',
52 52 :default_value => 'false',
53 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 57 :key => 'system.online_registration',
58 58 :value_type => 'boolean',
59 59 :default_value => 'false',
60 60 :description => 'This option enables online registration.'
61 61 },
62 62
63 63 # If Configuration['system.online_registration'] is true, the
64 64 # system allows online registration, and will use these
65 65 # information for sending confirmation emails.
66 66 {
67 67 :key => 'system.online_registration.smtp',
68 68 :value_type => 'string',
69 69 :default_value => 'smtp.somehost.com'
70 70 },
71 71
72 72 {
73 73 :key => 'system.online_registration.from',
74 74 :value_type => 'string',
75 75 :default_value => 'your.email@address'
76 76 },
77 77
78 78 {
79 79 :key => 'system.admin_email',
80 80 :value_type => 'string',
81 81 :default_value => 'admin@admin.email'
82 82 },
83 83
84 84 {
85 85 :key => 'system.user_setting_enabled',
86 86 :value_type => 'boolean',
87 87 :default_value => 'true',
88 88 :description => 'If this option is true, users can change their settings'
89 89 },
90 90
91 91 # If Configuration['contest.test_request.early_timeout'] is true
92 92 # the user will not be able to use test request at 30 minutes
93 93 # before the contest ends.
94 94 {
95 95 :key => 'contest.test_request.early_timeout',
96 96 :value_type => 'boolean',
97 97 :default_value => 'false'
98 98 },
99 99
100 100 {
101 101 :key => 'system.multicontests',
102 102 :value_type => 'boolean',
103 103 :default_value => 'false'
104 104 },
105 105
106 106 {
107 107 :key => 'contest.confirm_indv_contest_start',
108 108 :value_type => 'boolean',
109 109 :default_value => 'false'
110 110 },
111 111
112 112 {
113 113 :key => 'contest.default_contest_name',
114 114 :value_type => 'string',
115 115 :default_value => 'none',
116 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 122 def create_configuration_key(key,
123 123 value_type,
124 124 default_value,
125 125 description='')
126 126 conf = (GraderConfiguration.find_by_key(key) ||
127 127 GraderConfiguration.new(:key => key,
128 128 :value_type => value_type,
129 129 :value => default_value))
130 130 conf.description = description
131 131 conf.save
132 132 end
133 133
134 134 def seed_config
135 135 CONFIGURATIONS.each do |conf|
136 136 if conf.has_key? :description
137 137 desc = conf[:description]
138 138 else
139 139 desc = ''
140 140 end
141 141 create_configuration_key(conf[:key],
142 142 conf[:value_type],
143 143 conf[:default_value],
144 144 desc)
145 145 end
146 146 end
147 147
148 148 def seed_roles
149 149 return if Role.find_by_name('admin')
150 150
151 151 role = Role.create(:name => 'admin')
152 152 user_admin_right = Right.create(:name => 'user_admin',
153 153 :controller => 'user_admin',
154 154 :action => 'all')
155 155 problem_admin_right = Right.create(:name=> 'problem_admin',
156 156 :controller => 'problems',
157 157 :action => 'all')
158 158
159 159 graders_right = Right.create(:name => 'graders_admin',
160 160 :controller => 'graders',
161 161 :action => 'all')
162 162
163 163 role.rights << user_admin_right;
164 164 role.rights << problem_admin_right;
165 165 role.rights << graders_right;
166 166 role.save
167 167 end
168 168
169 169 def seed_root
170 170 return if User.find_by_login('root')
171 171
172 172 root = User.new(:login => 'root',
173 173 :full_name => 'Administrator',
174 174 :alias => 'root')
175 175 root.password = 'ioionrails';
176 176
177 177 class << root
178 178 public :encrypt_new_password
179 179 def valid?(context=nil)
180 180 true
181 181 end
182 182 end
183 183
184 184 root.encrypt_new_password
185 185
186 186 root.roles << Role.find_by_name('admin')
187 187
188 188 root.activated = true
189 189 root.save
190 190 end
191 191
192 192 def seed_users_and_roles
193 193 seed_roles
194 194 seed_root
195 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 207 seed_config
198 208 seed_users_and_roles
209 + seed_more_languages
You need to be logged in to leave comments. Login now