##// END OF EJS Templates
Don't force download of PDF (#22483)....
Don't force download of PDF (#22483). Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@15409 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r15027:3e776af8066e
Show More
news.rb
98 lines | 3.2 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
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 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
Jean-Philippe Lang
Removed unneeded :foreign_key option on belongs_to associations....
r13102 belongs_to :author, :class_name => 'User'
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 has_many :comments, lambda {order("created_on")}, :as => :commented, :dependent => :delete_all
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 rails-4.1 branch (#14534)....
r13100 attr_protected :id
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663
Jean-Philippe Lang
Edit attachments after upload (#1326)....
r13283 acts_as_attachable :edit_permission => :manage_news,
:delete_permission => :manage_news
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"],
Jean-Philippe Lang
Rewrites search engine to properly paginate results (#18631)....
r13357 :preload => :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
Merged rails-4.1 branch (#14534)....
r13100 acts_as_activity_provider :scope => preload(:project, :author),
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 :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|
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 joins(:project).
where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
Jean-Philippe Lang
Rewrites named scopes with ARel queries....
r10723 }
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
Add support for multiple email addresses per user (#4244)....
r13504 def notified_users
project.users.select {|user| user.notify_about?(self) && user.allowed_to?(:view_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
Add support for multiple email addresses per user (#4244)....
r13504 notified_users.map(&:mail)
Jean-Philippe Lang
Always notify project members about news unless they turned off all notifications (#4700)....
r11041 end
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 # Returns the users that should be cc'd when a new news is added
def notified_watchers_for_added_news
watchers = []
Jean-Philippe Lang
Enable the watching of news (#2549)....
r12591 if m = project.enabled_module('news')
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 watchers = m.notified_watchers
Jean-Philippe Lang
Enable the watching of news (#2549)....
r12591 unless project.is_public?
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 watchers = watchers.select {|user| project.users.include?(user)}
Jean-Philippe Lang
Enable the watching of news (#2549)....
r12591 end
end
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 watchers
end
# Returns the email addresses that should be cc'd when a new news is added
def cc_for_added_news
notified_watchers_for_added_news.map(&:mail)
Jean-Philippe Lang
Enable the watching of news (#2549)....
r12591 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)
Jean-Philippe Lang
Preload users and projects for latest news on welcome page....
r13184 visible(user).preload(:author, :project).order("#{News.table_name}.created_on DESC").limit(count).to_a
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