pagecontent/app/controllers/admin/page_contents_controller.rb

44 lines
1.0 KiB
Ruby
Raw Normal View History

2014-05-06 09:20:15 +00:00
class Admin::PageContentsController < OrbitAdminController
2014-05-05 07:05:59 +00:00
def index
2014-08-07 10:48:51 +00:00
@table_fields = [:page_id, :name,:version,:update_at,:last_modified]
@filter_fields = {}
@pages = Page.where(:module=>"page_content").order_by(sort)
@pages = search_data(@pages,[:name, :page_id]).page(params[:page]).per(10)
render :partial => "index" if request.xhr?
2014-05-06 09:20:15 +00:00
end
def show
@page_context = PageContext.find(params[:id])
end
def new
2014-07-31 12:42:42 +00:00
if can_edit_or_delete?(nil)
@page = Page.find(params[:page_id])
@page_content = PageContext.new
else
render_401
end
2014-05-06 09:20:15 +00:00
end
def create
2014-08-05 06:45:30 +00:00
@page_content = PageContext.new(update_params)
2014-05-06 09:20:15 +00:00
@page_content.update_user_id = current_user.id
2014-08-05 06:45:30 +00:00
@page_content.save
redirect_to params['referer_url']
2014-05-06 09:20:15 +00:00
end
def view
@table_fields = ["Name","Version","Updated At","Last Modified By"]
@page = Page.find(params[:id])
@page_contexts = @page.page_contexts.desc(:version)
end
private
def update_params
2014-08-07 10:48:51 +00:00
params.require(:page_context).permit!
2014-05-05 07:05:59 +00:00
end
end