74 lines
1.5 KiB
Ruby
74 lines
1.5 KiB
Ruby
class Admin::PagesController < ApplicationController
|
|
|
|
layout "content"
|
|
|
|
before_filter :authenticate_user!
|
|
before_filter :find_parent_item
|
|
before_filter :is_admin?
|
|
before_filter :set_current_item
|
|
|
|
def show
|
|
@item = Page.find(params[:id])
|
|
respond_to do |format|
|
|
format.html {
|
|
render 'admin/items/index'
|
|
}
|
|
format.js {}
|
|
end
|
|
end
|
|
|
|
def new
|
|
@item = Page.new
|
|
@item.is_published = true
|
|
@item.parent_id = @parent_item.id rescue nil
|
|
@designs = Design.all.entries
|
|
@default_design = @designs.detect {|d| d.title.to_s == 'Bob' }
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def create
|
|
@item = Page.new(params[:page])
|
|
if @item.save
|
|
@item.create_parts
|
|
@item.save
|
|
flash.now[:notice] = t('admin.create_success_page')
|
|
respond_to do |format|
|
|
format.html {
|
|
redirect_to admin_page_url(@item)
|
|
}
|
|
format.js {}
|
|
end
|
|
else
|
|
flash.now[:error] = t('admin.create_error_page')
|
|
@i18n_variable = @item.i18n_variable
|
|
render :action => "new"
|
|
end
|
|
end
|
|
|
|
def update
|
|
end
|
|
|
|
def destroy
|
|
@item = Page.find(params[:id])
|
|
@item.destroy
|
|
@item.destroy_page_parts
|
|
@item.destroy_i18n_variable
|
|
respond_to do |format|
|
|
format.html {
|
|
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
|
}
|
|
format.js {}
|
|
end
|
|
end
|
|
|
|
def delete
|
|
respond_to do |format|
|
|
format.html {}
|
|
format.js { destroy }
|
|
end
|
|
end
|
|
|
|
end
|