mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Backported r9134 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.3-stable@9151 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
210419047c
commit
985c885f98
@ -67,8 +67,8 @@ class NewsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@news = News.new(:project => @project, :author => User.current)
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
|
@news.safe_attributes = params[:news]
|
||||||
if request.post?
|
if request.post?
|
||||||
@news.attributes = params[:news]
|
|
||||||
if @news.save
|
if @news.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
||||||
@ -82,7 +82,8 @@ class NewsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if request.put? and @news.update_attributes(params[:news])
|
@news.safe_attributes = params[:news]
|
||||||
|
if request.put? and @news.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'show', :id => @news
|
redirect_to :action => 'show', :id => @news
|
||||||
else
|
else
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class News < ActiveRecord::Base
|
class News < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||||
@ -37,6 +38,8 @@ class News < ActiveRecord::Base
|
|||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
safe_attributes 'title', 'summary', 'description'
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_news, project)
|
!user.nil? && user.allowed_to?(:view_news, project)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user