summaryrefslogtreecommitdiffstats
path: root/app/models/document.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/document.rb')
-rw-r--r--app/models/document.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/document.rb b/app/models/document.rb
index 3aae39850..21232a2d9 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -29,6 +29,9 @@ class Document < ActiveRecord::Base
validates_presence_of :project, :title, :category
validates_length_of :title, :maximum => 60
+ named_scope :visible, lambda {|*args| { :include => :project,
+ :conditions => Project.allowed_to_condition(args.first || User.current, :view_documents) } }
+
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_documents, project)
end