##// END OF EJS Templates
Merged r3668 from trunk....
Jean-Philippe Lang -
r3583:4a295e723e37
parent child
Show More
@@ -46,11 +46,13 class VersionsController < ApplicationController
46 end
46 end
47
47
48 def destroy
48 def destroy
49 @version.destroy
49 if @version.fixed_issues.empty?
50 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
50 @version.destroy
51 rescue
51 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
52 flash[:error] = l(:notice_unable_delete_version)
52 else
53 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
53 flash[:error] = l(:notice_unable_delete_version)
54 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
55 end
54 end
56 end
55
57
56 def status_by
58 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
@@ -155,10 +154,7 class Version < ActiveRecord::Base
155 end
154 end
156 end
155 end
157
156
158 private
157 private
159 def check_integrity
160 raise "Can't delete version" if self.fixed_issues.find(:first)
161 end
162
158
163 # Update the issue's fixed versions. Used if a version's sharing changes.
159 # Update the issue's fixed versions. Used if a version's sharing changes.
164 def update_issues_from_sharing_change
160 def update_issues_from_sharing_change
General Comments 0
You need to be logged in to leave comments. Login now