Mercurial > hg > soundsoftware-site
comparison app/models/watcher.rb @ 1338:25603efa57b5
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:14 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
1209:1b1138f6f55e | 1338:25603efa57b5 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
19 belongs_to :watchable, :polymorphic => true | 19 belongs_to :watchable, :polymorphic => true |
20 belongs_to :user | 20 belongs_to :user |
21 | 21 |
22 validates_presence_of :user | 22 validates_presence_of :user |
23 validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id] | 23 validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id] |
24 validate :validate_user | |
24 | 25 |
25 # Unwatch things that users are no longer allowed to view | 26 # Unwatch things that users are no longer allowed to view |
26 def self.prune(options={}) | 27 def self.prune(options={}) |
27 if options.has_key?(:user) | 28 if options.has_key?(:user) |
28 prune_single_user(options[:user], options) | 29 prune_single_user(options[:user], options) |
35 end | 36 end |
36 end | 37 end |
37 | 38 |
38 protected | 39 protected |
39 | 40 |
40 def validate | 41 def validate_user |
41 errors.add :user_id, :invalid unless user.nil? || user.active? | 42 errors.add :user_id, :invalid unless user.nil? || user.active? |
42 end | 43 end |
43 | 44 |
44 private | 45 private |
45 | 46 |