Do not raise an error when destroying a Version with assigned issues.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3668 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c76b9edf6c
commit
9ccccb9984
|
@ -80,11 +80,13 @@ class VersionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@version.destroy
|
if @version.fixed_issues.empty?
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
@version.destroy
|
||||||
rescue
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
flash[:error] = l(:notice_unable_delete_version)
|
else
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
flash[:error] = l(:notice_unable_delete_version)
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_by
|
def status_by
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
@ -16,10 +16,9 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Version < ActiveRecord::Base
|
class Version < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
|
||||||
after_update :update_issues_from_sharing_change
|
after_update :update_issues_from_sharing_change
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
|
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
acts_as_attachable :view_permission => :view_files,
|
acts_as_attachable :view_permission => :view_files,
|
||||||
:delete_permission => :manage_files
|
:delete_permission => :manage_files
|
||||||
|
@ -156,10 +155,7 @@ class Version < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
|
||||||
raise "Can't delete version" if self.fixed_issues.find(:first)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Update the issue's fixed versions. Used if a version's sharing changes.
|
# Update the issue's fixed versions. Used if a version's sharing changes.
|
||||||
def update_issues_from_sharing_change
|
def update_issues_from_sharing_change
|
||||||
|
|
Loading…
Reference in New Issue