##// 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 end
80 end
81
81
82 def destroy
82 def destroy
83 @version.destroy
83 if @version.fixed_issues.empty?
84 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
84 @version.destroy
85 rescue
85 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
86 flash[:error] = l(:notice_unable_delete_version)
86 else
87 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
87 flash[:error] = l(:notice_unable_delete_version)
88 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
89 end
88 end
90 end
89
91
90 def status_by
92 def status_by
@@ -1,5 +1,5
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006-2010 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
@@ -16,10 +16,9
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 before_destroy :check_integrity
20 after_update :update_issues_from_sharing_change
19 after_update :update_issues_from_sharing_change
21 belongs_to :project
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 acts_as_customizable
22 acts_as_customizable
24 acts_as_attachable :view_permission => :view_files,
23 acts_as_attachable :view_permission => :view_files,
25 :delete_permission => :manage_files
24 :delete_permission => :manage_files
@@ -156,10 +155,7 class Version < ActiveRecord::Base
156 end
155 end
157 end
156 end
158
157
159 private
158 private
160 def check_integrity
161 raise "Can't delete version" if self.fixed_issues.find(:first)
162 end
163
159
164 # Update the issue's fixed versions. Used if a version's sharing changes.
160 # Update the issue's fixed versions. Used if a version's sharing changes.
165 def update_issues_from_sharing_change
161 def update_issues_from_sharing_change
General Comments 0
You need to be logged in to leave comments. Login now