Description:
shows only enabled contests, ordered by name
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r285:011d92099790 - - 3 files changed: 4 inserted, 2 deleted
@@ -193,13 +193,13 | |||
|
193 | 193 | end |
|
194 | 194 | end |
|
195 | 195 | |
|
196 | 196 | def problem_list_by_user_contests(user) |
|
197 | 197 | contest_problems = [] |
|
198 | 198 | pin = {} |
|
199 | - user.contests.each do |contest| | |
|
199 | + user.contests.enabled.each do |contest| | |
|
200 | 200 | available_problems = contest.problems.available |
|
201 | 201 | contest_problems << { |
|
202 | 202 | :contest => contest, |
|
203 | 203 | :problems => available_problems |
|
204 | 204 | } |
|
205 | 205 | available_problems.each {|p| pin[p.id] = true} |
@@ -1,6 +1,8 | |||
|
1 | 1 | class Contest < ActiveRecord::Base |
|
2 | 2 | |
|
3 | 3 | has_and_belongs_to_many :users |
|
4 | 4 | has_and_belongs_to_many :problems |
|
5 | 5 | |
|
6 | + named_scope :enabled, :conditions => {:enabled => true} | |
|
7 | + | |
|
6 | 8 | end |
@@ -18,13 +18,13 | |||
|
18 | 18 | |
|
19 | 19 | has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy |
|
20 | 20 | |
|
21 | 21 | belongs_to :site |
|
22 | 22 | belongs_to :country |
|
23 | 23 | |
|
24 | - has_and_belongs_to_many :contests, :uniq => true | |
|
24 | + has_and_belongs_to_many :contests, :uniq => true, :order => 'name' | |
|
25 | 25 | |
|
26 | 26 | named_scope :activated_users, :conditions => {:activated => true} |
|
27 | 27 | |
|
28 | 28 | validates_presence_of :login |
|
29 | 29 | validates_uniqueness_of :login |
|
30 | 30 | validates_format_of :login, :with => /^[\_A-Za-z0-9]+$/ |
You need to be logged in to leave comments.
Login now