1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 class EnumerationsController < ApplicationController
21 before_filter :require_admin
24 include CustomFieldsHelper
28 render :action => 'list'
31 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
32 verify :method => :post, :only => [ :destroy, :create, :update ],
33 :redirect_to => { :action => :list }
40 @enumeration = params[:type].constantize.new
42 @enumeration = Enumeration.new
47 @enumeration = Enumeration.new(params[:enumeration])
48 @enumeration.type = params[:enumeration][:type]
50 flash[:notice] = l(:notice_successful_create)
51 redirect_to :action => 'list', :type => @enumeration.type
53 render :action => 'new'
58 @enumeration = Enumeration.find(params[:id])
62 @enumeration = Enumeration.find(params[:id])
63 @enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
64 if @enumeration.update_attributes(params[:enumeration])
65 flash[:notice] = l(:notice_successful_update)
66 redirect_to :action => 'list', :type => @enumeration.type
68 render :action => 'edit'
73 @enumeration = Enumeration.find(params[:id])
74 if !@enumeration.in_use?
75 # No associated objects
77 redirect_to :action => 'index'
78 elsif params[:reassign_to_id]
79 if reassign_to = Enumeration.find_by_type_and_id(@enumeration.type, params[:reassign_to_id])
80 @enumeration.destroy(reassign_to)
81 redirect_to :action => 'index'
84 @enumerations = Enumeration.find(:all, :conditions => ['type = (?)', @enumeration.type]) - [@enumeration]
86 # flash[:error] = 'Unable to delete enumeration'
87 # redirect_to :action => 'index'