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

68 lines
1.4 KiB
Ruby

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])
case @part.kind
when 'text'
@i18n_variable = @part.i18n_variable
@partial = 'edit_text'
@part_locale = params[:part_locale] || I18n.locale.to_s
when 'module'
@plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/blog/widget_index"}]}]
when 'snippet'
end
end
def create
end
def update
@part = PagePart.find(params[:id])
if @part.update_attributes(params[:page_part])
flash.now[:notice] = t('admin.update_success_content')
@part.build_content(@site_valid_locales)
@part.save
respond_to do |format|
format.html {
redirect_to admin_page_url( @part.page )
}
format.js {
@item = @part.page
}
end
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