summaryrefslogtreecommitdiffstats
path: root/app/controllers/enumerations_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-17 17:29:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-17 17:29:27 +0000
commitd62b90db7327be488007d382f84c469f9fbe4ffe (patch)
tree153cfe41553b040154ecc89605b797864a76f3c1 /app/controllers/enumerations_controller.rb
parentfcb22595d0e87a2d04fb0210c775efdab6cfffa6 (diff)
downloadredmine-d62b90db7327be488007d382f84c469f9fbe4ffe.tar.gz
redmine-d62b90db7327be488007d382f84c469f9fbe4ffe.zip
Makes enumerations available through the REST API.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10664 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/enumerations_controller.rb')
-rw-r--r--app/controllers/enumerations_controller.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb
index 73a6ebd79..6eddff738 100644
--- a/app/controllers/enumerations_controller.rb
+++ b/app/controllers/enumerations_controller.rb
@@ -18,13 +18,26 @@
class EnumerationsController < ApplicationController
layout 'admin'
- before_filter :require_admin
+ before_filter :require_admin, :except => :index
+ before_filter :require_admin_or_api_request, :only => :index
before_filter :build_new_enumeration, :only => [:new, :create]
before_filter :find_enumeration, :only => [:edit, :update, :destroy]
+ accept_api_auth :index
helper :custom_fields
def index
+ respond_to do |format|
+ format.html
+ format.api {
+ @klass = Enumeration.get_subclass(params[:type])
+ if @klass
+ @enumerations = @klass.shared.sorted.all
+ else
+ render_404
+ end
+ }
+ end
end
def new
@@ -33,7 +46,7 @@ class EnumerationsController < ApplicationController
def create
if request.post? && @enumeration.save
flash[:notice] = l(:notice_successful_create)
- redirect_to :action => 'index', :type => @enumeration.type
+ redirect_to :action => 'index'
else
render :action => 'new'
end
@@ -45,7 +58,7 @@ class EnumerationsController < ApplicationController
def update
if request.put? && @enumeration.update_attributes(params[:enumeration])
flash[:notice] = l(:notice_successful_update)
- redirect_to :action => 'index', :type => @enumeration.type
+ redirect_to :action => 'index'
else
render :action => 'edit'
end