2010-01-14 10:30:53 +00:00
|
|
|
class Admin::LinksController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
2010-03-04 08:33:26 +00:00
|
|
|
before_filter :authenticate_user!
|
2010-01-14 10:30:53 +00:00
|
|
|
before_filter :find_parent_item
|
2011-04-13 10:19:51 +00:00
|
|
|
before_filter :is_admin?
|
2010-01-14 10:30:53 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
#TODO
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@link = Link.new
|
|
|
|
@link.is_published = true
|
2011-04-13 10:19:51 +00:00
|
|
|
@link.parent_id = @parent_item.id rescue nil
|
|
|
|
session[:last_page] = get_go_back || admin_links_url
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@link = Link.find(params[:id])
|
2011-04-13 10:19:51 +00:00
|
|
|
@i18n_variable = @link.i18n_variable
|
|
|
|
session[:last_page] = get_go_back || admin_links_url
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@link = Link.new(params[:link])
|
|
|
|
|
|
|
|
if @link.save
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.create_success_link')
|
|
|
|
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
|
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@link = Link.find(params[:id])
|
|
|
|
|
|
|
|
if @link.update_attributes(params[:link])
|
2011-04-13 10:19:51 +00:00
|
|
|
flash[:notice] = t('admin.update_success_link')
|
|
|
|
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
|
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@link = Link.find(params[:id])
|
|
|
|
@link.destroy
|
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|