This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/pages_controller.rb

55 lines
1.2 KiB
Ruby

class Admin::PagesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
def show
#TODO
end
def new
@page = Page.new
@page.is_published = true
@page.parent_id = @parent_item.id rescue nil
session[:last_page] = get_go_back || admin_items_url
end
def edit
@page = Page.find(params[:id])
@i18n_variable = @page.i18n_variable
session[:last_page] = get_go_back || admin_items_url
end
def create
@page = Page.new(params[:page])
if @page.save
flash[:notice] = t('admin.create_success_page')
redirect_to admin_items_url( :parent_id => @page.parent_id )
else
render :action => "new"
end
end
def update
@page = Page.find(params[:id])
if @page.update_attributes(params[:page])
flash[:notice] = t('admin.update_success_page')
redirect_to admin_items_url( :parent_id => @page.parent_id )
else
render :action => "edit"
end
end
def destroy
@page = Page.find(params[:id])
@page.destroy
@page.destroy_i18n_variable
redirect_to admin_items_url( :parent_id => @page.parent_id )
end
end