diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-12-12 17:00:52 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-12-12 17:00:52 +0000 |
commit | ac60fc9c1c587ba1f600c7d17723d2b88f2b6bed (patch) | |
tree | cb6b99fd80e8e2107dd6dcf140bec7e354af8c70 /app/models | |
parent | aaee26ae229f1f6cc863094aa58f32c434c98c58 (diff) | |
download | redmine-ac60fc9c1c587ba1f600c7d17723d2b88f2b6bed.tar.gz redmine-ac60fc9c1c587ba1f600c7d17723d2b88f2b6bed.zip |
Refactor and add tests for News #index API (#7072).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4505 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/news.rb | 5 |
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 |