summaryrefslogtreecommitdiffstats
path: root/app/models/news.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/news.rb')
-rw-r--r--app/models/news.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/news.rb b/app/models/news.rb
index a167cdf38..00729f06c 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -29,6 +29,11 @@ class News < ActiveRecord::Base
acts_as_activity_provider :find_options => {:include => [:project, :author]},
:author_key => :author_id
+ named_scope :visible, lambda {|*args| {
+ :include => :project,
+ :conditions => Project.allowed_to_condition(args.first || User.current, :view_news)
+ }}
+
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_news, project)
end