##// END OF EJS Templates
Do not raise an error when destroying a Version with assigned issues....
Jean-Philippe Lang -
r3554:9ccccb998485
parent child
Show More
@@ -80,11 +80,13 class VersionsController < ApplicationController
80 80 end
81 81
82 82 def destroy
83 @version.destroy
84 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
85 rescue
86 flash[:error] = l(:notice_unable_delete_version)
87 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
83 if @version.fixed_issues.empty?
84 @version.destroy
85 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
86 else
87 flash[:error] = l(:notice_unable_delete_version)
88 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
89 end
88 90 end
89 91
90 92 def status_by
@@ -1,5 +1,5
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -16,10 +16,9
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class Version < ActiveRecord::Base
19 before_destroy :check_integrity
20 19 after_update :update_issues_from_sharing_change
21 20 belongs_to :project
22 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
21 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
23 22 acts_as_customizable
24 23 acts_as_attachable :view_permission => :view_files,
25 24 :delete_permission => :manage_files
@@ -156,10 +155,7 class Version < ActiveRecord::Base
156 155 end
157 156 end
158 157
159 private
160 def check_integrity
161 raise "Can't delete version" if self.fixed_issues.find(:first)
162 end
158 private
163 159
164 160 # Update the issue's fixed versions. Used if a version's sharing changes.
165 161 def update_issues_from_sharing_change
General Comments 0
You need to be logged in to leave comments. Login now