comparison app/models/changeset.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children 4f746d8966dd
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
13 # 13 #
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 require 'iconv'
19
20 class Changeset < ActiveRecord::Base 18 class Changeset < ActiveRecord::Base
21 belongs_to :repository 19 belongs_to :repository
22 belongs_to :user 20 belongs_to :user
23 has_many :filechanges, :class_name => 'Change', :dependent => :delete_all 21 has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
24 has_and_belongs_to_many :issues 22 has_and_belongs_to_many :issues
47 45
48 validates_presence_of :repository_id, :revision, :committed_on, :commit_date 46 validates_presence_of :repository_id, :revision, :committed_on, :commit_date
49 validates_uniqueness_of :revision, :scope => :repository_id 47 validates_uniqueness_of :revision, :scope => :repository_id
50 validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true 48 validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
51 49
52 scope :visible, 50 scope :visible, lambda {|*args|
53 lambda {|*args| { :include => {:repository => :project}, 51 includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
54 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } } 52 }
55 53
56 after_create :scan_for_issues 54 after_create :scan_for_issues
57 before_create :before_create_cs 55 before_create :before_create_cs
58 56
59 def revision=(r) 57 def revision=(r)