REST API for issue categories (#9553).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7882 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
6f4fb8b892
commit
34c73c7573
10 files changed
+218
-27
No files matched your search
@@ -18,18 +18,33 @@
|
||||
class IssueCategoriesController < ApplicationController
|
||||
menu_item :settings
|
||||
model_object IssueCategory
|
||||
before_filter :find_model_object, :except => [:new, :create]
|
||||
before_filter :find_project_from_association, :except => [:new, :create]
|
||||
before_filter :find_project, :only => [:new, :create]
|
||||
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 :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 }
|
||||
format.api { @categories = @project.issue_categories.all }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project }
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@category = @project.issue_categories.build(params[:category])
|
||||
@category = @project.issue_categories.build(params[:issue_category])
|
||||
end
|
||||
|
||||
verify :method => :post, :only => :create
|
||||
def create
|
||||
@category = @project.issue_categories.build(params[:category])
|
||||
@category = @project.issue_categories.build(params[:issue_category])
|
||||
if @category.save
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@@ -42,6 +57,7 @@ class IssueCategoriesController < ApplicationController
|
||||
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.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -49,6 +65,7 @@ class IssueCategoriesController < ApplicationController
|
||||
format.js do
|
||||
render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
|
||||
end
|
||||
format.api { render_validation_errors(@category) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -58,26 +75,35 @@ class IssueCategoriesController < ApplicationController
|
||||
|
||||
verify :method => :put, :only => :update
|
||||
def update
|
||||
if @category.update_attributes(params[:category])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||
if @category.update_attributes(params[:issue_category])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||
}
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
render :action => 'edit'
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'edit' }
|
||||
format.api { render_validation_errors(@category) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
verify :method => :delete, :only => :destroy
|
||||
def destroy
|
||||
@issue_count = @category.issues.size
|
||||
if @issue_count == 0
|
||||
# No issue assigned to this category
|
||||
@category.destroy
|
||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
||||
return
|
||||
elsif params[:todo]
|
||||
reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
|
||||
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])
|
||||
end
|
||||
@category.destroy(reassign_to)
|
||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
|
||||
format.api { head :ok }
|
||||
end
|
||||
return
|
||||
end
|
||||
@categories = @project.issue_categories - [@category]
|
||||
|
||||
Reference in new issue
Block a user