diff options
Diffstat (limited to 'app/controllers/enumerations_controller.rb')
-rw-r--r-- | app/controllers/enumerations_controller.rb | 19 |
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 |