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

56 lines
1.2 KiB
Ruby
Raw Normal View History

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