Uniformized: @page and @ link in @item
Change parser for page edition.
This commit is contained in:
1 parent
3d97c5bfda
commit
d971a8ecbe
20 files changed
+246
-73
No files matched your search
@@ -8,10 +8,9 @@ class Admin::PagesController < ApplicationController
|
||||
before_filter :set_current_item
|
||||
|
||||
def show
|
||||
@page = Page.find(params[:id])
|
||||
@item = Page.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@item = @page
|
||||
render 'admin/items/index'
|
||||
}
|
||||
format.js {}
|
||||
@@ -19,47 +18,47 @@ class Admin::PagesController < ApplicationController
|
||||
end
|
||||
|
||||
def new
|
||||
@page = Page.new
|
||||
@page.is_published = true
|
||||
@page.parent_id = @parent_item.id rescue nil
|
||||
@item = Page.new
|
||||
@item.is_published = true
|
||||
@item.parent_id = @parent_item.id rescue nil
|
||||
end
|
||||
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
@page.content = parse_content(@page.content, {:locale => 'show'})
|
||||
@i18n_variable = @page.i18n_variable
|
||||
@item = Page.find(params[:id])
|
||||
@item.content = parse_content(@item.content, {:locale => 'show'})
|
||||
@i18n_variable = @item.i18n_variable
|
||||
end
|
||||
|
||||
def create
|
||||
@page = Page.new(params[:page])
|
||||
@page.content = parse_content(@page.content, {:locale => 'create'})
|
||||
if @page.save
|
||||
@item = Page.new(params[:page])
|
||||
@item.content = parse_content(@item.content, {:locale => 'create'})
|
||||
if @item.save
|
||||
flash[:notice] = t('admin.create_success_page')
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@page = Page.find(params[:id])
|
||||
parse_content(@page.content, {:locale => 'destroy'})
|
||||
if @page.update_attributes(params[:page])
|
||||
@page.content = parse_content(@page.content, {:locale => 'create'})
|
||||
@page.save!
|
||||
@item = Page.find(params[:id])
|
||||
parse_content(@item.content, {:locale => 'destroy'})
|
||||
if @item.update_attributes(params[:page])
|
||||
@item.content = parse_content(@item.content, {:locale => 'create'})
|
||||
@item.save!
|
||||
flash[:notice] = t('admin.update_success_page')
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@page = Page.find(params[:id])
|
||||
@page.destroy
|
||||
@page.destroy_i18n_variable
|
||||
@item = Page.find(params[:id])
|
||||
@item.destroy
|
||||
@item.destroy_i18n_variable
|
||||
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user