comparison app/models/document.rb @ 929:5f33065ddc4b redmine-1.3

Update to Redmine SVN rev 9414 on 1.3-stable branch
author Chris Cannam
date Wed, 27 Jun 2012 14:54:18 +0100
parents cbce1fd3b1b7
children 433d4f72a19b
comparison
equal deleted inserted replaced
909:cbb26bc654de 929:5f33065ddc4b
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 class Document < ActiveRecord::Base 18 class Document < ActiveRecord::Base
19 include Redmine::SafeAttributes
19 belongs_to :project 20 belongs_to :project
20 belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" 21 belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
21 acts_as_attachable :delete_permission => :manage_documents 22 acts_as_attachable :delete_permission => :manage_documents
22 23
23 acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project 24 acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
29 validates_presence_of :project, :title, :category 30 validates_presence_of :project, :title, :category
30 validates_length_of :title, :maximum => 60 31 validates_length_of :title, :maximum => 60
31 32
32 named_scope :visible, lambda {|*args| { :include => :project, 33 named_scope :visible, lambda {|*args| { :include => :project,
33 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } } 34 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
35
36 safe_attributes 'category_id', 'title', 'description'
34 37
35 def visible?(user=User.current) 38 def visible?(user=User.current)
36 !user.nil? && user.allowed_to?(:view_documents, project) 39 !user.nil? && user.allowed_to?(:view_documents, project)
37 end 40 end
38 41