From e41afb4fe907b15406d8120e05a3f31c8acfdd87 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 7 Mar 2012 18:35:22 +0000 Subject: [PATCH] Backported r9137 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.3-stable@9153 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/versions_controller.rb | 7 ++++--- app/models/version.rb | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index a4d08fdd6..b9e3583f6 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -75,7 +75,7 @@ class VersionsController < ApplicationController if params[:version] attributes = params[:version].dup attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) - @version.attributes = attributes + @version.safe_attributes = attributes end end @@ -85,7 +85,7 @@ class VersionsController < ApplicationController if params[:version] attributes = params[:version].dup attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) - @version.attributes = attributes + @version.safe_attributes = attributes end if request.post? @@ -124,7 +124,8 @@ class VersionsController < ApplicationController if request.put? && params[:version] attributes = params[:version].dup attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) - if @version.update_attributes(attributes) + @version.safe_attributes = attributes + if @version.save respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) diff --git a/app/models/version.rb b/app/models/version.rb index 2681ef23d..e1c81918f 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Version < ActiveRecord::Base + include Redmine::SafeAttributes after_update :update_issues_from_sharing_change belongs_to :project has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify @@ -38,6 +39,15 @@ class Version < ActiveRecord::Base named_scope :visible, lambda {|*args| { :include => :project, :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } + safe_attributes 'name', + 'description', + 'effective_date', + 'due_date', + 'wiki_page_title', + 'status', + 'sharing', + 'custom_field_values' + # Returns true if +user+ or current user is allowed to view the version def visible?(user=User.current) user.allowed_to?(:view_issues, self.project)