Links edition
This commit is contained in:
1 parent
d9ba76ebd5
commit
24ae7ed5e3
31 files changed
+184
-98
No files matched your search
@@ -6,12 +6,14 @@ class Admin::ItemsController < ApplicationController
|
||||
before_filter :find_parent_item
|
||||
before_filter :find_snippets, :only => :index
|
||||
before_filter :is_admin?
|
||||
before_filter :set_current_item
|
||||
|
||||
def index
|
||||
if params[:item_id]
|
||||
@page = Item.find(params[:item_id])
|
||||
@item = Item.find(params[:item_id])
|
||||
else
|
||||
@page = Item.first(:conditions => {:parent_id => nil})
|
||||
@item = Item.first(:conditions => {:parent_id => nil})
|
||||
@page = @item
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
class Admin::LinksController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
layout "content"
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :is_admin?
|
||||
|
||||
def show
|
||||
#TODO
|
||||
@link ||= Link.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@link = Link.new
|
||||
@link.is_published = true
|
||||
@link.parent_id = @parent_item.id rescue nil
|
||||
@link.parent_id = Page.find(params[:parent_id]).id rescue nil
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -24,10 +25,17 @@ class Admin::LinksController < ApplicationController
|
||||
@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 )
|
||||
flash.now[:notice] = t('admin.create_success_link')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_link_url(@link)
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
else
|
||||
render :action => "new"
|
||||
flash.now[:error] = t('admin.create_error_link')
|
||||
@i18n_variable = @link.i18n_variable
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,9 +43,16 @@ class Admin::LinksController < ApplicationController
|
||||
@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 )
|
||||
flash.now[:notice] = t('admin.update_success_link')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_link_url(@link)
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('admin.update_error_link')
|
||||
@i18n_variable = @link.i18n_variable
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
@@ -46,8 +61,16 @@ class Admin::LinksController < ApplicationController
|
||||
@link = Link.find(params[:id])
|
||||
@link.destroy
|
||||
@link.destroy_i18n_variable
|
||||
|
||||
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
||||
end
|
||||
|
||||
def delete
|
||||
destroy
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_items_url
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,12 +1,21 @@
|
||||
class Admin::PagesController < ApplicationController
|
||||
|
||||
layout "content"
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :is_admin?
|
||||
before_filter :set_current_item
|
||||
|
||||
def show
|
||||
#TODO
|
||||
@page = Page.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@item = @page
|
||||
render 'admin/items/index'
|
||||
}
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
include Parser
|
||||
|
||||
helper :all
|
||||
before_filter :set_locale, :set_site
|
||||
before_filter :set_locale, :set_site
|
||||
|
||||
# Find the parent for the given item
|
||||
def find_parent_item
|
||||
@@ -51,5 +51,9 @@ class ApplicationController < ActionController::Base
|
||||
@site_in_use_locales = @site.in_use_locales
|
||||
@site_valid_locales = @site.valid_locales
|
||||
end
|
||||
|
||||
def set_current_item
|
||||
session[:current_page] = params[:id] || @page.id || @link.id || @item.id rescue nil
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user