Mercurial > hg > soundsoftware-site
diff app/models/document.rb @ 1338:25603efa57b5
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:14 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 261b3d9a4903 |
line wrap: on
line diff
--- a/app/models/document.rb Wed Jan 23 13:11:25 2013 +0000 +++ b/app/models/document.rb Thu Jun 20 13:14:14 2013 +0100 @@ -1,5 +1,5 @@ -# RedMine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ validates_presence_of :project, :title, :category validates_length_of :title, :maximum => 60 - named_scope :visible, lambda {|*args| { :include => :project, + scope :visible, lambda {|*args| { :include => :project, :conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } } safe_attributes 'category_id', 'title', 'description' @@ -39,7 +39,8 @@ !user.nil? && user.allowed_to?(:view_documents, project) end - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? self.category ||= DocumentCategory.default end @@ -47,7 +48,7 @@ def updated_on unless @updated_on - a = attachments.find(:first, :order => 'created_on DESC') + a = attachments.last @updated_on = (a && a.created_on) || created_on end @updated_on