comparison app/models/version.rb @ 929:5f33065ddc4b redmine-1.3

Update to Redmine SVN rev 9414 on 1.3-stable branch
author Chris Cannam
date Wed, 27 Jun 2012 14:54:18 +0100
parents cbb26bc654de
children 433d4f72a19b
comparison
equal deleted inserted replaced
909:cbb26bc654de 929:5f33065ddc4b
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 class Version < ActiveRecord::Base 18 class Version < ActiveRecord::Base
19 include Redmine::SafeAttributes
19 after_update :update_issues_from_sharing_change 20 after_update :update_issues_from_sharing_change
20 belongs_to :project 21 belongs_to :project
21 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify 22 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
22 acts_as_customizable 23 acts_as_customizable
23 acts_as_attachable :view_permission => :view_files, 24 acts_as_attachable :view_permission => :view_files,
35 36
36 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}} 37 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
37 named_scope :open, :conditions => {:status => 'open'} 38 named_scope :open, :conditions => {:status => 'open'}
38 named_scope :visible, lambda {|*args| { :include => :project, 39 named_scope :visible, lambda {|*args| { :include => :project,
39 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } 40 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
41
42 safe_attributes 'name',
43 'description',
44 'effective_date',
45 'due_date',
46 'wiki_page_title',
47 'status',
48 'sharing',
49 'custom_field_values'
40 50
41 # Returns true if +user+ or current user is allowed to view the version 51 # Returns true if +user+ or current user is allowed to view the version
42 def visible?(user=User.current) 52 def visible?(user=User.current)
43 user.allowed_to?(:view_issues, self.project) 53 user.allowed_to?(:view_issues, self.project)
44 end 54 end