Class: News

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Redmine::SafeAttributes
Defined in:
app/models/news.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Redmine::SafeAttributes

#delete_unsafe_attributes, included, #safe_attribute_names, #safe_attributes=

Class Method Details

.latest(user = User.current, count = 5) ⇒ Object

returns latest news for projects visible by user


49
50
51
# File 'app/models/news.rb', line 49

def self.latest(user = User.current, count = 5)
  find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
end

Instance Method Details

#commentable?(user = User.current) ⇒ Boolean

Returns true if the news can be commented by user

Returns:

  • (Boolean)

44
45
46
# File 'app/models/news.rb', line 44

def commentable?(user=User.current)
  user.allowed_to?(:comment_news, project)
end

#visible?(user = User.current) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
# File 'app/models/news.rb', line 39

def visible?(user=User.current)
  !user.nil? && user.allowed_to?(:view_news, project)
end