Mercurial > hg > soundsoftware-site
diff app/controllers/custom_fields_controller.rb @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | 433d4f72a19b |
children | e248c7af89ec |
line wrap: on
line diff
--- a/app/controllers/custom_fields_controller.rb Fri Jun 14 09:05:06 2013 +0100 +++ b/app/controllers/custom_fields_controller.rb Tue Jan 14 14:37:42 2014 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -21,20 +21,28 @@ before_filter :require_admin before_filter :build_new_custom_field, :only => [:new, :create] before_filter :find_custom_field, :only => [:edit, :update, :destroy] + accept_api_auth :index def index - @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } - @tab = params[:tab] || 'IssueCustomField' + respond_to do |format| + format.html { + @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name } + @tab = params[:tab] || 'IssueCustomField' + } + format.api { + @custom_fields = CustomField.all + } + end end def new end def create - if request.post? and @custom_field.save + if @custom_field.save flash[:notice] = l(:notice_successful_create) call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field) - redirect_to :action => 'index', :tab => @custom_field.class.name + redirect_to custom_fields_path(:tab => @custom_field.class.name) else render :action => 'new' end @@ -44,21 +52,22 @@ end def update - if request.put? and @custom_field.update_attributes(params[:custom_field]) + if @custom_field.update_attributes(params[:custom_field]) flash[:notice] = l(:notice_successful_update) call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field) - redirect_to :action => 'index', :tab => @custom_field.class.name + redirect_to custom_fields_path(:tab => @custom_field.class.name) else render :action => 'edit' end end def destroy - @custom_field.destroy - redirect_to :action => 'index', :tab => @custom_field.class.name - rescue - flash[:error] = l(:error_can_not_delete_custom_field) - redirect_to :action => 'index' + begin + @custom_field.destroy + rescue + flash[:error] = l(:error_can_not_delete_custom_field) + end + redirect_to custom_fields_path(:tab => @custom_field.class.name) end private @@ -67,6 +76,8 @@ @custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field]) if @custom_field.nil? render_404 + else + @custom_field.default_value = nil end end