53 lines
1.0 KiB
Ruby
53 lines
1.0 KiB
Ruby
|
class Admin::HomesController < ApplicationController
|
||
|
|
||
|
layout "admin"
|
||
|
before_filter :authenticate_user!
|
||
|
before_filter :is_admin?
|
||
|
|
||
|
def show
|
||
|
#TODO
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@home = Home.new
|
||
|
@home.is_published = true
|
||
|
@home.parent_id = nil
|
||
|
session[:last_page] = get_go_back || admin_items_url
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
@home = Home.find(params[:id])
|
||
|
@i18n_variable = @home.i18n_variable
|
||
|
session[:last_page] = get_go_back || admin_items_url
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
@home = Home.new(params[:home])
|
||
|
|
||
|
if @home.save
|
||
|
flash[:notice] = t('admin.create_success_home')
|
||
|
redirect_to admin_items_url
|
||
|
else
|
||
|
render :action => "new"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def update
|
||
|
@home = Home.find(params[:id])
|
||
|
if @home.update_attributes(params[:home])
|
||
|
flash[:notice] = t('admin.update_success_home')
|
||
|
redirect_to admin_items_url
|
||
|
else
|
||
|
render :action => "edit"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
@home = Home.find(params[:id])
|
||
|
@home.destroy
|
||
|
|
||
|
redirect_to admin_items_url
|
||
|
end
|
||
|
|
||
|
end
|