2009-05-07 17:54:33 +00:00
|
|
|
class Admin::LayoutsController < ApplicationController
|
2009-05-07 18:13:27 +00:00
|
|
|
|
|
|
|
layout "admin"
|
2010-03-04 08:33:26 +00:00
|
|
|
before_filter :authenticate_user!
|
2011-04-13 10:19:51 +00:00
|
|
|
before_filter :is_admin?
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2009-05-07 17:54:33 +00:00
|
|
|
def index
|
2011-04-13 10:19:51 +00:00
|
|
|
@layouts = Layout.all.entries
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2011-04-13 10:19:51 +00:00
|
|
|
#TODO
|
|
|
|
# @layout = Layout.find(params[:id])
|
|
|
|
# redirect_to "/#{@layout.name}"
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@layout = Layout.new
|
2011-04-13 10:19:51 +00:00
|
|
|
session[:last_page] = get_go_back || admin_layouts_url
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@layout = Layout.find(params[:id])
|
2011-04-13 10:19:51 +00:00
|
|
|
session[:last_page] = get_go_back || admin_layouts_url
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@layout = Layout.new(params[:layout])
|
|
|
|
|
2010-01-04 09:49:55 +00:00
|
|
|
if @layout.save
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.create_success_layout')
|
2010-01-04 09:49:55 +00:00
|
|
|
redirect_to admin_layouts_url
|
|
|
|
else
|
2011-04-13 10:19:51 +00:00
|
|
|
render :action => 'new'
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@layout = Layout.find(params[:id])
|
2010-01-04 09:49:55 +00:00
|
|
|
|
|
|
|
if @layout.update_attributes(params[:layout])
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.update_success_layout')
|
2010-01-04 09:49:55 +00:00
|
|
|
redirect_to admin_layouts_url
|
|
|
|
else
|
|
|
|
render :action => "edit"
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@layout = Layout.find(params[:id])
|
|
|
|
@layout.destroy
|
|
|
|
|
2010-01-04 09:49:55 +00:00
|
|
|
redirect_to admin_layouts_url
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|
2010-01-04 09:49:55 +00:00
|
|
|
|
2009-05-07 17:54:33 +00:00
|
|
|
end
|