comparison app/models/news.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 ec1c49528f36 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 News < ActiveRecord::Base 18 class News < ActiveRecord::Base
19 include Redmine::SafeAttributes
19 belongs_to :project 20 belongs_to :project
20 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' 21 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
21 has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" 22 has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
22 23
23 validates_presence_of :title, :description 24 validates_presence_of :title, :description
35 named_scope :visible, lambda {|*args| { 36 named_scope :visible, lambda {|*args| {
36 :include => :project, 37 :include => :project,
37 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args) 38 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
38 }} 39 }}
39 40
41 safe_attributes 'title', 'summary', 'description'
42
40 def visible?(user=User.current) 43 def visible?(user=User.current)
41 !user.nil? && user.allowed_to?(:view_news, project) 44 !user.nil? && user.allowed_to?(:view_news, project)
42 end 45 end
43 46
44 # returns latest news for projects visible by user 47 # returns latest news for projects visible by user