##// END OF EJS Templates
Blank content type for attachments attached via Ajax file upload (Patch by Jens Krämer)....
Blank content type for attachments attached via Ajax file upload (Patch by Jens Krämer). git-svn-id: http://svn.redmine.org/redmine/trunk@13125 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r12639:98e299857bc4
r12850:61776a8b7e60
Show More
news.rb
85 lines | 3.0 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Fixed: Latest news appear on the homepage for projects with the News module disabled (#1941)....
r1908 # Redmine - project management software
Toshi MARUYAMA
update copyright year (#15977)...
r12461 # Copyright (C) 2006-2014 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class News < ActiveRecord::Base
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a news (#10390)....
r9014 include Redmine::SafeAttributes
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 belongs_to :project
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 validates_presence_of :title, :description
Jean-Philippe Lang
Added several validates_length_of...
r590 validates_length_of :title, :maximum => 60
validates_length_of :summary, :maximum => 255
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663
Jean-Philippe Lang
Allows attachments on news (#1972)....
r8608 acts_as_attachable :delete_permission => :manage_news
Jean-Philippe Lang
Fixed: News summary field is not searchable (#2998)....
r2552 acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663 acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 acts_as_activity_provider :find_options => {:include => [:project, :author]},
:author_key => :author_id
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 acts_as_watchable
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 after_create :add_author_as_watcher
Jean-Philippe Lang
Use AR callbacks instead of observers (removed in Rails4) for notifications....
r11791 after_create :send_notification
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Rewrites named scopes with ARel queries....
r10723 scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
}
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a news (#10390)....
r9014 safe_attributes 'title', 'summary', 'description'
Jean-Philippe Lang
Make sure users don't get notified for thing they can not view (#3589)....
r3055 def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_news, project)
end
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds a News#commentable? method to easily specific additional rules....
r8734 # Returns true if the news can be commented by user
def commentable?(user=User.current)
user.allowed_to?(:comment_news, project)
end
Jean-Philippe Lang
Always notify project members about news unless they turned off all notifications (#4700)....
r11041 def recipients
Jean-Philippe Lang
Only notify users that can see news (#16134)....
r12639 project.users.select {|user| user.notify_about?(self) && user.allowed_to?(:view_news, project)}.map(&:mail)
Jean-Philippe Lang
Always notify project members about news unless they turned off all notifications (#4700)....
r11041 end
Jean-Philippe Lang
Enable the watching of news (#2549)....
r12591 # Returns the email addresses that should be cc'd when a new news is added
def cc_for_added_news
cc = []
if m = project.enabled_module('news')
cc = m.notified_watchers
unless project.is_public?
cc = cc.select {|user| project.users.include?(user)}
end
end
cc.map(&:mail)
end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # returns latest news for projects visible by user
Jean-Philippe Lang
Fixed: Latest news appear on the homepage for projects with the News module disabled (#1941)....
r1908 def self.latest(user = User.current, count = 5)
Toshi MARUYAMA
backout r12540 : remove unneeded Relation#all from News#latest...
r12291 visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
Jean-Philippe Lang
Localization plugin removed (replaced with GLoc)...
r12 end
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 private
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 def add_author_as_watcher
Watcher.create(:watchable => self, :user => author)
end
Jean-Philippe Lang
Use AR callbacks instead of observers (removed in Rails4) for notifications....
r11791
def send_notification
if Setting.notified_events.include?('news_added')
Mailer.news_added(self).deliver
end
end
Jean-Philippe Lang
Initial commit...
r2 end