Mercurial > hg > soundsoftware-site
comparison app/controllers/custom_fields_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | cbce1fd3b1b7 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 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 |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 class CustomFieldsController < ApplicationController | 18 class CustomFieldsController < ApplicationController |
19 layout 'admin' | 19 layout 'admin' |
20 | 20 |
21 before_filter :require_admin | 21 before_filter :require_admin |
22 | 22 |
23 def index | 23 def index |
24 @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } | 24 @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } |
25 @tab = params[:tab] || 'IssueCustomField' | 25 @tab = params[:tab] || 'IssueCustomField' |
26 end | 26 end |
27 | 27 |
28 def new | 28 def new |
29 @custom_field = begin | 29 @custom_field = begin |
30 if params[:type].to_s.match(/.+CustomField$/) | 30 if params[:type].to_s.match(/.+CustomField$/) |
31 params[:type].to_s.constantize.new(params[:custom_field]) | 31 params[:type].to_s.constantize.new(params[:custom_field]) |
32 end | 32 end |
33 rescue | 33 rescue |
34 end | 34 end |
35 (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField) | 35 (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField) |
36 | 36 |
37 if request.post? and @custom_field.save | 37 if request.post? and @custom_field.save |
38 flash[:notice] = l(:notice_successful_create) | 38 flash[:notice] = l(:notice_successful_create) |
39 call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field) | 39 call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field) |
40 redirect_to :action => 'index', :tab => @custom_field.class.name | 40 redirect_to :action => 'index', :tab => @custom_field.class.name |
41 else | 41 else |
51 redirect_to :action => 'index', :tab => @custom_field.class.name | 51 redirect_to :action => 'index', :tab => @custom_field.class.name |
52 else | 52 else |
53 @trackers = Tracker.find(:all, :order => 'position') | 53 @trackers = Tracker.find(:all, :order => 'position') |
54 end | 54 end |
55 end | 55 end |
56 | 56 |
57 def destroy | 57 def destroy |
58 @custom_field = CustomField.find(params[:id]).destroy | 58 @custom_field = CustomField.find(params[:id]).destroy |
59 redirect_to :action => 'index', :tab => @custom_field.class.name | 59 redirect_to :action => 'index', :tab => @custom_field.class.name |
60 rescue | 60 rescue |
61 flash[:error] = l(:error_can_not_delete_custom_field) | 61 flash[:error] = l(:error_can_not_delete_custom_field) |