Improve code in items, pages, links

This commit is contained in:
Christophe Vilayphiou committed 2012-02-17 14:54:11 +08:00
1 parent cf4a6c0b35
commit 0b71714d44
7 files changed
+37 -63

No files matched your search

-15
View File
@@ -15,21 +15,6 @@ class Admin::ItemsController < ApplicationController
@item = get_homepage
end
end
#TODO
# Allow to move items down and up different parents
# def up
# @item = Item.find(params[:id])
# @item.move_higher
# redirect_to admin_items_url( :parent_name => @item.parent_name )
# end
#
# def down
# @item = Item.find(params[:id])
# @item.move_lower
# redirect_to admin_items_url( :parent_name => @item.parent_name )
# end
protected
+1 -5
View File
@@ -12,13 +12,11 @@ class Admin::LinksController < ApplicationController
def new
@item = Link.new
@item.is_published = true
@item.parent_id = Page.find(params[:parent_id]).id rescue nil
@item.parent = Page.find(params[:parent_id]) rescue nil
end
def edit
@item = Link.find(params[:id])
@i18n_variable = @item.i18n_variable
end
def create
@@ -34,7 +32,6 @@ class Admin::LinksController < ApplicationController
end
else
flash.now[:error] = t('admin.create_error_link')
@i18n_variable = @item.i18n_variable
render :action => "new"
end
end
@@ -52,7 +49,6 @@ class Admin::LinksController < ApplicationController
end
else
flash.now[:error] = t('admin.update_error_link')
@i18n_variable = @item.i18n_variable
render :action => "edit"
end
end
+6 -6
View File
@@ -19,19 +19,17 @@ class Admin::PagesController < ApplicationController
def new
@item = Page.new
@item.parent = Item.find(params[:parent_id]) rescue nil
@apps = ModuleApp.all
@item.is_published = true
@item.parent_id = @parent_item.id rescue nil
@designs = Design.all.entries
@default_design = Design.first
@design = Design.first
end
def edit
@item = Page.find(params[:id])
@apps = ModuleApp.all
@i18n_variable = @item.i18n_variable
@designs = Design.all.entries
@design = @item.design
@design = @item.design ? @item.design : @designs.first
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
end
@@ -47,7 +45,9 @@ class Admin::PagesController < ApplicationController
end
else
flash.now[:error] = t('admin.create_error_page')
@i18n_variable = @item.i18n_variable
@apps = ModuleApp.all
@designs = Design.all.entries
@design = Design.first
render :action => "new"
end
end
+10 -7
View File
@@ -13,13 +13,16 @@ class PagesController < ApplicationController
def show
#begin
item = Item.first(:conditions => {:full_name => params[:page_name]})
case item._type
when 'Page'
@item = item
render_page(params[:id])
when 'Link'
redirect_to "http://#{item[:url]}"
@item = Item.first(:conditions => {:full_name => params[:page_name]})
if @item.is_published
case @item._type
when 'Page'
render_page(params[:id])
when 'Link'
redirect_to "http://#{@item[:url]}"
end
else
render :file => "#{Rails.root}/public/404.html", :status => :not_found
end
#rescue
# render :file => "#{Rails.root}/public/404.html", :status => :not_found