summaryrefslogtreecommitdiffstats
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-03 11:28:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-03 11:28:44 +0000
commite9775097ec5da895cece3085915865faa4a51710 (patch)
tree89a66f3dcbdbe44ba70ae300ca04548ad70af6b3 /app/controllers/users_controller.rb
parent96ce0f017cfe58210d84e5092446395b811ccdab (diff)
downloadredmine-e9775097ec5da895cece3085915865faa4a51710.tar.gz
redmine-e9775097ec5da895cece3085915865faa4a51710.zip
Adds xml/json REST API for Users (#6260).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4453 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abb32c4ff..ff118e744 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,5 +1,5 @@
# Redmine - project management software
-# Copyright (C) 2006-2009 Jean-Philippe Lang
+# Copyright (C) 2006-2010 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
@@ -19,6 +19,7 @@ class UsersController < ApplicationController
layout 'admin'
before_filter :require_admin, :except => :show
+ accept_key_auth :index, :show, :create, :update
helper :sort
include SortHelper
@@ -48,6 +49,8 @@ class UsersController < ApplicationController
respond_to do |format|
format.html { render :layout => !request.xhr? }
+ format.json { render :template => 'users/index.apit' }
+ format.xml { render :template => 'users/index.apit' }
end
end
@@ -69,6 +72,8 @@ class UsersController < ApplicationController
respond_to do |format|
format.html { render :layout => 'base' }
+ format.json { render :template => 'users/show.apit' }
+ format.xml { render :template => 'users/show.apit' }
end
rescue ActiveRecord::RecordNotFound
render_404
@@ -111,6 +116,8 @@ class UsersController < ApplicationController
{:controller => 'users', :action => 'edit', :id => @user}
)
}
+ format.json { render :template => 'users/show.apit', :status => :created, :location => user_url(@user) }
+ format.xml { render :template => 'users/show.apit', :status => :created, :location => user_url(@user) }
end
else
@auth_sources = AuthSource.find(:all)
@@ -118,6 +125,8 @@ class UsersController < ApplicationController
respond_to do |format|
format.html { render :action => 'new' }
+ format.json { render :json => {:errors => @user.errors}, :status => :unprocessable_entity, :layout => false }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity, :layout => false }
end
end
end
@@ -166,6 +175,8 @@ class UsersController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to :back
}
+ format.json { head :ok }
+ format.xml { head :ok }
end
else
@auth_sources = AuthSource.find(:all)
@@ -173,6 +184,8 @@ class UsersController < ApplicationController
respond_to do |format|
format.html { render :action => :edit }
+ format.json { render :json => {:errors => @user.errors}, :status => :unprocessable_entity, :layout => false }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity, :layout => false }
end
end
rescue ::ActionController::RedirectBackError