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.6 KiB
Ruby
Raw Normal View History

class Admin::LinksController < ApplicationController
2011-05-13 01:08:42 +00:00
layout "content"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
def show
2011-05-13 01:08:42 +00:00
@link ||= Link.find(params[:id])
end
def new
@link = Link.new
@link.is_published = true
2011-05-13 01:08:42 +00:00
@link.parent_id = Page.find(params[:parent_id]).id rescue nil
end
def edit
@link = Link.find(params[:id])
@i18n_variable = @link.i18n_variable
end
def create
@link = Link.new(params[:link])
if @link.save
2011-05-13 01:08:42 +00:00
flash.now[:notice] = t('admin.create_success_link')
respond_to do |format|
format.html {
redirect_to admin_link_url(@link)
}
format.js {}
end
else
2011-05-13 01:08:42 +00:00
flash.now[:error] = t('admin.create_error_link')
@i18n_variable = @link.i18n_variable
render :action => "new"
end
end
def update
@link = Link.find(params[:id])
if @link.update_attributes(params[:link])
2011-05-13 01:08:42 +00:00
flash.now[:notice] = t('admin.update_success_link')
respond_to do |format|
format.html {
redirect_to admin_link_url(@link)
}
format.js {}
end
else
2011-05-13 01:08:42 +00:00
flash.now[:error] = t('admin.update_error_link')
@i18n_variable = @link.i18n_variable
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
2011-05-13 01:08:42 +00:00
end
def delete
destroy
respond_to do |format|
format.html {
redirect_to admin_items_url
}
format.js {}
end
end
end