Description:
added default contest
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r308:c400f7405eee - - 3 files changed: 23 inserted, 1 deleted
@@ -54,7 +54,7 | |||
|
54 | 54 | redirect_to :action => 'list' |
|
55 | 55 | else |
|
56 | 56 | render :action => 'new' |
|
57 | - end | |
|
57 | + end | |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def create_from_list |
@@ -53,6 +53,7 | |||
|
53 | 53 | |
|
54 | 54 | before_save :encrypt_new_password |
|
55 | 55 | before_save :assign_default_site |
|
56 | + before_save :assign_default_contest | |
|
56 | 57 | |
|
57 | 58 | # this is for will_paginate |
|
58 | 59 | cattr_reader :per_page |
@@ -273,6 +274,19 | |||
|
273 | 274 | end |
|
274 | 275 | end |
|
275 | 276 | |
|
277 | + def assign_default_contest | |
|
278 | + # have to catch error when migrating (because self.site is not available). | |
|
279 | + begin | |
|
280 | + if self.contests.length == 0 | |
|
281 | + default_contest = Contest.find_by_name(Configuration['contest.default_contest_name']) | |
|
282 | + if default_contest | |
|
283 | + self.contests = [default_contest] | |
|
284 | + end | |
|
285 | + end | |
|
286 | + rescue | |
|
287 | + end | |
|
288 | + end | |
|
289 | + | |
|
276 | 290 | def password_required? |
|
277 | 291 | self.hashed_password.blank? || !self.password.blank? |
|
278 | 292 | end |
@@ -107,7 +107,15 | |||
|
107 | 107 | :key => 'contest.confirm_indv_contest_start', |
|
108 | 108 | :value_type => 'boolean', |
|
109 | 109 | :default_value => 'false' |
|
110 | + }, | |
|
111 | + | |
|
112 | + { | |
|
113 | + :key => 'contest.default_contest_name', | |
|
114 | + :value_type => 'string', | |
|
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." | |
|
110 | 117 | } |
|
118 | + | |
|
111 | 119 | ] |
|
112 | 120 | |
|
113 | 121 |
You need to be logged in to leave comments.
Login now