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

55 lines
1.1 KiB
Ruby
Raw Normal View History

class Admin::PagePartsController < ApplicationController
layout "content"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_current_item
def show
@part = PagePart.find(params[:id])
respond_to do |format|
format.html {
render 'admin/items/index'
}
format.js {}
end
end
def new
end
def edit
@part = PagePart.find(params[:id])
#@part.content = parse_content(@part.content, {:locale => 'show'})
# @part = @part.i18n_variable
end
def create
end
def update
@part = PagePart.find(params[:id])
parse_content(@part.content, {:locale => 'destroy'})
if @part.update_attributes(params[:page])
@part.content = parse_content(@part.content, {:locale => 'create'})
@part.save!
flash[:notice] = t('admin.update_success_page')
redirect_to admin_items_url( :parent_id => @part.page_id )
else
render :action => "edit"
end
end
def destroy
@item = Page.find(params[:id])
@item.destroy
@item.destroy_i18n_variable
redirect_to admin_items_url( :parent_id => @item.parent_id )
end
end