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

@@ -101,98 +101,109
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