comparison app/models/.svn/text-base/issue_status.rb.svn-base @ 1:cca12e1c1fd4

* Update to Redmine trunk (SVN revisions 3860-3892)
author Chris Cannam
date Wed, 28 Jul 2010 12:08:28 +0100
parents 513646585e45
children 8661b858af72
comparison
equal deleted inserted replaced
0:513646585e45 1:cca12e1c1fd4
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 IssueStatus < ActiveRecord::Base 18 class IssueStatus < ActiveRecord::Base
19 before_destroy :check_integrity 19 before_destroy :check_integrity
20 has_many :workflows, :foreign_key => "old_status_id", :dependent => :delete_all 20 has_many :workflows, :foreign_key => "old_status_id"
21 acts_as_list 21 acts_as_list
22
23 before_destroy :delete_workflows
22 24
23 validates_presence_of :name 25 validates_presence_of :name
24 validates_uniqueness_of :name 26 validates_uniqueness_of :name
25 validates_length_of :name, :maximum => 30 27 validates_length_of :name, :maximum => 30
26 validates_format_of :name, :with => /^[\w\s\'\-]*$/i 28 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
87 89
88 private 90 private
89 def check_integrity 91 def check_integrity
90 raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id]) 92 raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
91 end 93 end
94
95 # Deletes associated workflows
96 def delete_workflows
97 Workflow.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
98 end
92 end 99 end