diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-06 10:06:32 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-06 10:06:32 +0000 |
commit | be246de16121b2c4751a8f6bfa8b0eedec767b56 (patch) | |
tree | 35ed59874026b66a786a45cd154a8c6838cc5706 /app/controllers/roles_controller.rb | |
parent | c5665276b7a465f29230341f8800af4f77b3c141 (diff) | |
download | redmine-be246de16121b2c4751a8f6bfa8b0eedec767b56.tar.gz redmine-be246de16121b2c4751a8f6bfa8b0eedec767b56.zip |
Adds a simple API for listing roles (#9725).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8799 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/roles_controller.rb')
-rw-r--r-- | app/controllers/roles_controller.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index cfdc133bf..9c6c1652d 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -18,13 +18,21 @@ class RolesController < ApplicationController layout 'admin' - before_filter :require_admin + before_filter :require_admin, :except => :index + before_filter :require_admin_or_api_request, :only => :index before_filter :find_role, :only => [:edit, :update, :destroy] - + accept_api_auth :index def index - @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position' - render :action => "index", :layout => false if request.xhr? + respond_to do |format| + format.html { + @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position' + render :action => "index", :layout => false if request.xhr? + } + format.api { + @roles = Role.givable.all + } + end end def new |