Sha256: d4e53da60c836a92d5df236e103a8a411c9ca46392544cbf8dc344e4f6e94733

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Kuhsaft
  module Admin
    class PagesController < ApplicationController
      respond_to :html
      layout 'kuhsaft/admin'
      before_filter :set_translation_locale
      helper :all
      
      def index
        @pages = Kuhsaft::Page.root_pages
        respond_with @pages
      end
    
      def show
        @page = Kuhsaft::Page.find(params[:id])
        respond_with @page
      end
    
      def new
        @page = Kuhsaft::Page.new
        respond_with @page
      end
    
      def create
        @page = Kuhsaft::Page.create params[:kuhsaft_page]
        @page.save
        respond_with @page, :location => admin_pages_path
      end
    
      def edit
        @page = Kuhsaft::Page.find(params[:id])
        respond_with @page
      end
    
      def update
        @page = Kuhsaft::Page.find(params[:id])
        @page.update_attributes(params[:kuhsaft_page]) if params[:kuhsaft_page].present?
        # TODO: refactor 'reposition' as a page attribute, so it can be set through update_attributes
        @page.reposition params[:reposition] if params[:reposition].present? || params.key?(:reposition)
        respond_with @page, :location => admin_pages_path
      end
    
      def destroy
        @page = Kuhsaft::Page.find(params[:id])
        @page.destroy
        redirect_to admin_pages_path
      end
      
      def set_translation_locale
        Kuhsaft::Page.current_translation_locale = params[:translation_locale] if params[:translation_locale].present?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kuhsaft-0.0.3 app/controllers/kuhsaft/admin/pages_controller.rb