This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/links_controller.rb

77 lines
1.5 KiB
Ruby
Raw Normal View History

class Admin::LinksController < ApplicationController
layout "site_editor"
2011-05-13 01:08:42 +00:00
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
def show
@item ||= Link.find(params[:id])
end
def new
@item = Link.new
2012-02-17 06:54:11 +00:00
@item.parent = Page.find(params[:parent_id]) rescue nil
end
def edit
@item = Link.find(params[:id])
end
def create
@item = Link.new(params[:link])
if @item.save
2012-09-12 11:12:50 +00:00
flash.now[:notice] = t('create.success.link')
2011-05-13 01:08:42 +00:00
respond_to do |format|
format.html {
redirect_to admin_link_url(@item)
2011-05-13 01:08:42 +00:00
}
format.js {}
end
else
2012-09-12 11:12:50 +00:00
flash.now[:error] = t('create.error.link')
2011-05-13 01:08:42 +00:00
render :action => "new"
end
end
def update
@item = Link.find(params[:id])
if @item.update_attributes(params[:link])
2012-09-12 11:12:50 +00:00
flash.now[:notice] = t('update.success.link')
2011-05-13 01:08:42 +00:00
respond_to do |format|
format.html {
redirect_to admin_link_url(@item)
2011-05-13 01:08:42 +00:00
}
format.js {}
end
else
2012-09-12 11:12:50 +00:00
flash.now[:error] = t('update.error.link')
render :action => "edit"
end
end
def destroy
@item = Link.find(params[:id])
@item.destroy
2011-05-13 01:08:42 +00:00
respond_to do |format|
format.html {
redirect_to admin_items_url
}
format.js {}
end
end
2011-05-13 01:59:29 +00:00
def delete
2012-05-22 06:45:49 +00:00
@item = Link.find(params[:id])
@item.destroy
2011-05-13 01:59:29 +00:00
respond_to do |format|
format.html {}
2012-05-22 06:45:49 +00:00
format.js { @item = @item.parent }
2011-05-13 01:59:29 +00:00
end
end
end