summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-06-17 19:10:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-06-17 19:10:54 +0000
commit3c95f761e610a1d5957ca9f96708958ba80565ab (patch)
tree37efaadcfb59ffb57a003d8115c7528b21118de9 /app/controllers
parentf4e0c77c8357958e713466c000e135e321600249 (diff)
downloadredmine-3c95f761e610a1d5957ca9f96708958ba80565ab.tar.gz
redmine-3c95f761e610a1d5957ca9f96708958ba80565ab.zip
Ability to remove enumerations (activities, priorities, document categories) that are in use. Associated objects can be reassigned to another value (#1467).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1558 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/enumerations_controller.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb
index 7a7f1685a..788fa11b2 100644
--- a/app/controllers/enumerations_controller.rb
+++ b/app/controllers/enumerations_controller.rb
@@ -75,11 +75,20 @@ class EnumerationsController < ApplicationController
end
def destroy
- Enumeration.find(params[:id]).destroy
- flash[:notice] = l(:notice_successful_delete)
- redirect_to :action => 'list'
- rescue
- flash[:error] = "Unable to delete enumeration"
- redirect_to :action => 'list'
+ @enumeration = Enumeration.find(params[:id])
+ if !@enumeration.in_use?
+ # No associated objects
+ @enumeration.destroy
+ redirect_to :action => 'index'
+ elsif params[:reassign_to_id]
+ if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id])
+ @enumeration.destroy(reassign_to)
+ redirect_to :action => 'index'
+ end
+ end
+ @enumerations = Enumeration.get_values(@enumeration.opt) - [@enumeration]
+ #rescue
+ # flash[:error] = 'Unable to delete enumeration'
+ # redirect_to :action => 'index'
end
end