orbit-basic/app/controllers/admin/pages_controller.rb

57 lines
1.4 KiB
Ruby
Raw Normal View History

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
2009-05-22 06:43:52 +00:00
@page.is_published = true
@page.parent_id = @parent_item.id rescue nil
end
def edit
@page = Page.find(params[:id])
@page.content = parse_content(@page.content, {:locale => 'show'})
@i18n_variable = @page.i18n_variable
end
def create
@page = Page.new(params[:page])
@page.content = parse_content(@page.content, {:locale => 'create'})
2010-01-04 09:49:55 +00:00
if @page.save
flash[:notice] = t('admin.create_success_page')
redirect_to admin_items_url( :parent_id => @page.parent_id )
2010-01-04 09:49:55 +00:00
else
render :action => "new"
end
end
def update
@page = Page.find(params[:id])
parse_content(@page.content, {:locale => 'destroy'})
2010-01-04 09:49:55 +00:00
if @page.update_attributes(params[:page])
@page.content = parse_content(@page.content, {:locale => 'create'})
@page.save!
flash[:notice] = t('admin.update_success_page')
redirect_to admin_items_url( :parent_id => @page.parent_id )
2010-01-04 09:49:55 +00:00
else
render :action => "edit"
end
end
def destroy
@page = Page.find(params[:id])
@page.destroy
2011-01-28 06:44:08 +00:00
@page.destroy_i18n_variable
redirect_to admin_items_url( :parent_id => @page.parent_id )
end
2010-01-04 09:49:55 +00:00
end