annotate .svn/pristine/cf/cf99c613decbc54df4a99c63e23764d371ea8fbc.svn-base @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents
children
rev   line source
Chris@1295 1 # Redmine - project management software
Chris@1295 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1295 3 #
Chris@1295 4 # This program is free software; you can redistribute it and/or
Chris@1295 5 # modify it under the terms of the GNU General Public License
Chris@1295 6 # as published by the Free Software Foundation; either version 2
Chris@1295 7 # of the License, or (at your option) any later version.
Chris@1295 8 #
Chris@1295 9 # This program is distributed in the hope that it will be useful,
Chris@1295 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1295 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1295 12 # GNU General Public License for more details.
Chris@1295 13 #
Chris@1295 14 # You should have received a copy of the GNU General Public License
Chris@1295 15 # along with this program; if not, write to the Free Software
Chris@1295 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1295 17
Chris@1295 18 class IssueCategoriesController < ApplicationController
Chris@1295 19 menu_item :settings
Chris@1295 20 model_object IssueCategory
Chris@1295 21 before_filter :find_model_object, :except => [:index, :new, :create]
Chris@1295 22 before_filter :find_project_from_association, :except => [:index, :new, :create]
Chris@1295 23 before_filter :find_project_by_project_id, :only => [:index, :new, :create]
Chris@1295 24 before_filter :authorize
Chris@1295 25 accept_api_auth :index, :show, :create, :update, :destroy
Chris@1295 26
Chris@1295 27 def index
Chris@1295 28 respond_to do |format|
Chris@1295 29 format.html { redirect_to_settings_in_projects }
Chris@1295 30 format.api { @categories = @project.issue_categories.all }
Chris@1295 31 end
Chris@1295 32 end
Chris@1295 33
Chris@1295 34 def show
Chris@1295 35 respond_to do |format|
Chris@1295 36 format.html { redirect_to_settings_in_projects }
Chris@1295 37 format.api
Chris@1295 38 end
Chris@1295 39 end
Chris@1295 40
Chris@1295 41 def new
Chris@1295 42 @category = @project.issue_categories.build
Chris@1295 43 @category.safe_attributes = params[:issue_category]
Chris@1295 44
Chris@1295 45 respond_to do |format|
Chris@1295 46 format.html
Chris@1295 47 format.js
Chris@1295 48 end
Chris@1295 49 end
Chris@1295 50
Chris@1295 51 def create
Chris@1295 52 @category = @project.issue_categories.build
Chris@1295 53 @category.safe_attributes = params[:issue_category]
Chris@1295 54 if @category.save
Chris@1295 55 respond_to do |format|
Chris@1295 56 format.html do
Chris@1295 57 flash[:notice] = l(:notice_successful_create)
Chris@1295 58 redirect_to_settings_in_projects
Chris@1295 59 end
Chris@1295 60 format.js
Chris@1295 61 format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
Chris@1295 62 end
Chris@1295 63 else
Chris@1295 64 respond_to do |format|
Chris@1295 65 format.html { render :action => 'new'}
Chris@1295 66 format.js { render :action => 'new'}
Chris@1295 67 format.api { render_validation_errors(@category) }
Chris@1295 68 end
Chris@1295 69 end
Chris@1295 70 end
Chris@1295 71
Chris@1295 72 def edit
Chris@1295 73 end
Chris@1295 74
Chris@1295 75 def update
Chris@1295 76 @category.safe_attributes = params[:issue_category]
Chris@1295 77 if @category.save
Chris@1295 78 respond_to do |format|
Chris@1295 79 format.html {
Chris@1295 80 flash[:notice] = l(:notice_successful_update)
Chris@1295 81 redirect_to_settings_in_projects
Chris@1295 82 }
Chris@1295 83 format.api { render_api_ok }
Chris@1295 84 end
Chris@1295 85 else
Chris@1295 86 respond_to do |format|
Chris@1295 87 format.html { render :action => 'edit' }
Chris@1295 88 format.api { render_validation_errors(@category) }
Chris@1295 89 end
Chris@1295 90 end
Chris@1295 91 end
Chris@1295 92
Chris@1295 93 def destroy
Chris@1295 94 @issue_count = @category.issues.size
Chris@1295 95 if @issue_count == 0 || params[:todo] || api_request?
Chris@1295 96 reassign_to = nil
Chris@1295 97 if params[:reassign_to_id] && (params[:todo] == 'reassign' || params[:todo].blank?)
Chris@1295 98 reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id])
Chris@1295 99 end
Chris@1295 100 @category.destroy(reassign_to)
Chris@1295 101 respond_to do |format|
Chris@1295 102 format.html { redirect_to_settings_in_projects }
Chris@1295 103 format.api { render_api_ok }
Chris@1295 104 end
Chris@1295 105 return
Chris@1295 106 end
Chris@1295 107 @categories = @project.issue_categories - [@category]
Chris@1295 108 end
Chris@1295 109
Chris@1295 110 private
Chris@1295 111
Chris@1295 112 def redirect_to_settings_in_projects
Chris@1295 113 redirect_to settings_project_path(@project, :tab => 'categories')
Chris@1295 114 end
Chris@1295 115
Chris@1295 116 # Wrap ApplicationController's find_model_object method to set
Chris@1295 117 # @category instead of just @issue_category
Chris@1295 118 def find_model_object
Chris@1295 119 super
Chris@1295 120 @category = @object
Chris@1295 121 end
Chris@1295 122 end