Mercurial > hg > soundsoftware-site
diff app/controllers/issue_categories_controller.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | 5f33065ddc4b |
children | 622f24f53b42 |
line wrap: on
line diff
--- a/app/controllers/issue_categories_controller.rb Wed Jun 27 14:54:18 2012 +0100 +++ b/app/controllers/issue_categories_controller.rb Mon Jan 07 12:01:42 2013 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 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 @@ -20,10 +20,10 @@ model_object IssueCategory before_filter :find_model_object, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] - before_filter :find_project, :only => [:index, :new, :create] + before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :authorize accept_api_auth :index, :show, :create, :update, :destroy - + def index respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project } @@ -41,9 +41,13 @@ def new @category = @project.issue_categories.build @category.safe_attributes = params[:issue_category] + + respond_to do |format| + format.html + format.js + end end - verify :method => :post, :only => :create def create @category = @project.issue_categories.build @category.safe_attributes = params[:issue_category] @@ -53,20 +57,13 @@ flash[:notice] = l(:notice_successful_create) redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project end - format.js do - # IE doesn't support the replace_html rjs method for select box options - render(:update) {|page| page.replace "issue_category_id", - content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') - } - end + format.js format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) } end else respond_to do |format| format.html { render :action => 'new'} - format.js do - render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } - end + format.js { render :action => 'new'} format.api { render_validation_errors(@category) } end end @@ -75,7 +72,6 @@ def edit end - verify :method => :put, :only => :update def update @category.safe_attributes = params[:issue_category] if @category.save @@ -84,7 +80,7 @@ flash[:notice] = l(:notice_successful_update) redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project } - format.api { head :ok } + format.api { render_api_ok } end else respond_to do |format| @@ -94,10 +90,9 @@ end end - verify :method => :delete, :only => :destroy def destroy @issue_count = @category.issues.size - if @issue_count == 0 || params[:todo] || api_request? + if @issue_count == 0 || params[:todo] || api_request? reassign_to = nil if params[:reassign_to_id] && (params[:todo] == 'reassign' || params[:todo].blank?) reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) @@ -105,7 +100,7 @@ @category.destroy(reassign_to) respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' } - format.api { head :ok } + format.api { render_api_ok } end return end @@ -119,10 +114,4 @@ super @category = @object end - - def find_project - @project = Project.find(params[:project_id]) - rescue ActiveRecord::RecordNotFound - render_404 - end end