To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / issue_categories_controller.rb @ 1535:e2c122809c5c
History | View | Annotate | Download (3.65 KB)
| 1 | 909:cbb26bc654de | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | 1494:e248c7af89ec | Chris | # Copyright (C) 2006-2014 Jean-Philippe Lang
|
| 3 | 0:513646585e45 | Chris | #
|
| 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.
|
||
| 8 | 909:cbb26bc654de | Chris | #
|
| 9 | 0:513646585e45 | Chris | # 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.
|
||
| 13 | 909:cbb26bc654de | Chris | #
|
| 14 | 0:513646585e45 | Chris | # 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.
|
||
| 17 | |||
| 18 | class IssueCategoriesController < ApplicationController |
||
| 19 | menu_item :settings
|
||
| 20 | model_object IssueCategory
|
||
| 21 | 909:cbb26bc654de | Chris | before_filter :find_model_object, :except => [:index, :new, :create] |
| 22 | before_filter :find_project_from_association, :except => [:index, :new, :create] |
||
| 23 | 1115:433d4f72a19b | Chris | before_filter :find_project_by_project_id, :only => [:index, :new, :create] |
| 24 | 0:513646585e45 | Chris | before_filter :authorize
|
| 25 | 909:cbb26bc654de | Chris | accept_api_auth :index, :show, :create, :update, :destroy |
| 26 | 1115:433d4f72a19b | Chris | |
| 27 | 909:cbb26bc654de | Chris | def index |
| 28 | respond_to do |format|
|
||
| 29 | 1464:261b3d9a4903 | Chris | format.html { redirect_to_settings_in_projects }
|
| 30 | 909:cbb26bc654de | Chris | format.api { @categories = @project.issue_categories.all }
|
| 31 | end
|
||
| 32 | end
|
||
| 33 | |||
| 34 | def show |
||
| 35 | respond_to do |format|
|
||
| 36 | 1464:261b3d9a4903 | Chris | format.html { redirect_to_settings_in_projects }
|
| 37 | 909:cbb26bc654de | Chris | format.api |
| 38 | end
|
||
| 39 | end
|
||
| 40 | 0:513646585e45 | Chris | |
| 41 | def new |
||
| 42 | 929:5f33065ddc4b | Chris | @category = @project.issue_categories.build |
| 43 | @category.safe_attributes = params[:issue_category] |
||
| 44 | 1115:433d4f72a19b | Chris | |
| 45 | respond_to do |format|
|
||
| 46 | format.html |
||
| 47 | format.js |
||
| 48 | end
|
||
| 49 | 909:cbb26bc654de | Chris | end
|
| 50 | |||
| 51 | def create |
||
| 52 | 929:5f33065ddc4b | Chris | @category = @project.issue_categories.build |
| 53 | @category.safe_attributes = params[:issue_category] |
||
| 54 | 909:cbb26bc654de | Chris | if @category.save |
| 55 | respond_to do |format|
|
||
| 56 | format.html do
|
||
| 57 | flash[:notice] = l(:notice_successful_create) |
||
| 58 | 1464:261b3d9a4903 | Chris | redirect_to_settings_in_projects |
| 59 | 0:513646585e45 | Chris | end
|
| 60 | 1115:433d4f72a19b | Chris | format.js |
| 61 | 909:cbb26bc654de | Chris | format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
| 62 | end
|
||
| 63 | else
|
||
| 64 | respond_to do |format|
|
||
| 65 | format.html { render :action => 'new'}
|
||
| 66 | 1115:433d4f72a19b | Chris | format.js { render :action => 'new'}
|
| 67 | 909:cbb26bc654de | Chris | format.api { render_validation_errors(@category) }
|
| 68 | 0:513646585e45 | Chris | end
|
| 69 | end
|
||
| 70 | end
|
||
| 71 | 909:cbb26bc654de | Chris | |
| 72 | 0:513646585e45 | Chris | def edit |
| 73 | 909:cbb26bc654de | Chris | end
|
| 74 | |||
| 75 | def update |
||
| 76 | 929:5f33065ddc4b | Chris | @category.safe_attributes = params[:issue_category] |
| 77 | if @category.save |
||
| 78 | 909:cbb26bc654de | Chris | respond_to do |format|
|
| 79 | format.html {
|
||
| 80 | flash[:notice] = l(:notice_successful_update) |
||
| 81 | 1464:261b3d9a4903 | Chris | redirect_to_settings_in_projects |
| 82 | 909:cbb26bc654de | Chris | } |
| 83 | 1115:433d4f72a19b | Chris | format.api { render_api_ok }
|
| 84 | 909:cbb26bc654de | Chris | end
|
| 85 | else
|
||
| 86 | respond_to do |format|
|
||
| 87 | format.html { render :action => 'edit' }
|
||
| 88 | format.api { render_validation_errors(@category) }
|
||
| 89 | end
|
||
| 90 | 0:513646585e45 | Chris | end
|
| 91 | end
|
||
| 92 | |||
| 93 | def destroy |
||
| 94 | @issue_count = @category.issues.size |
||
| 95 | 1115:433d4f72a19b | Chris | if @issue_count == 0 || params[:todo] || api_request? |
| 96 | 909:cbb26bc654de | Chris | reassign_to = nil
|
| 97 | if params[:reassign_to_id] && (params[:todo] == 'reassign' || params[:todo].blank?) |
||
| 98 | reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) |
||
| 99 | end
|
||
| 100 | 0:513646585e45 | Chris | @category.destroy(reassign_to)
|
| 101 | 909:cbb26bc654de | Chris | respond_to do |format|
|
| 102 | 1464:261b3d9a4903 | Chris | format.html { redirect_to_settings_in_projects }
|
| 103 | 1115:433d4f72a19b | Chris | format.api { render_api_ok }
|
| 104 | 909:cbb26bc654de | Chris | end
|
| 105 | 441:cbce1fd3b1b7 | Chris | return
|
| 106 | 0:513646585e45 | Chris | end
|
| 107 | @categories = @project.issue_categories - [@category] |
||
| 108 | end
|
||
| 109 | |||
| 110 | 1464:261b3d9a4903 | Chris | private |
| 111 | |||
| 112 | def redirect_to_settings_in_projects |
||
| 113 | redirect_to settings_project_path(@project, :tab => 'categories') |
||
| 114 | end
|
||
| 115 | |||
| 116 | 0:513646585e45 | Chris | # Wrap ApplicationController's find_model_object method to set
|
| 117 | # @category instead of just @issue_category
|
||
| 118 | def find_model_object |
||
| 119 | super
|
||
| 120 | @category = @object |
||
| 121 | 909:cbb26bc654de | Chris | end
|
| 122 | 0:513646585e45 | Chris | end |