2010-01-14 10:30:53 +00:00
|
|
|
class Admin::LinksController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
before_filter :find_parent_item
|
|
|
|
|
|
|
|
def show
|
|
|
|
#TODO
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@link = Link.new
|
|
|
|
@link.is_published = true
|
2010-01-18 07:52:52 +00:00
|
|
|
@link.parent_name = @parent_item.name
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@link = Link.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@link = Link.new(params[:link])
|
|
|
|
|
|
|
|
if @link.save
|
|
|
|
flash[:notice] = 'Link was successfully created.'
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
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])
|
|
|
|
flash[:notice] = 'Link was successfully updated.'
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
2010-01-14 10:30:53 +00:00
|
|
|
else
|
|
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@link = Link.find(params[:id])
|
|
|
|
@link.destroy
|
|
|
|
|
2010-01-18 07:52:52 +00:00
|
|
|
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
2010-01-14 10:30:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|