app/controllers/caboose/pages_controller.rb in caboose-cms-0.5.12 vs app/controllers/caboose/pages_controller.rb in caboose-cms-0.5.13
- old
+ new
@@ -138,11 +138,11 @@
end
# GET /admin/pages/new
def admin_new
return unless user_is_allowed('pages', 'add')
- @parent_id = params[:parent_id] ? params[:parent_id] : 1
+ @parent_id = params[:parent_id] ? params[:parent_id] : Page.where(:site_id => @site.id, :parent_id => -1).first.id
@parent = Page.find(@parent_id)
render :layout => 'caboose/admin'
end
# GET /admin/pages/:id/edit
@@ -281,11 +281,11 @@
render :json => resp
return
end
parent = Caboose::Page.find(parent_id)
- page = Caboose::Page.new
+ page = Caboose::Page.new
if parent.nil?
d = Domain.where(:domain => request.host_with_port).first.site_id
page.site_id = d.site_id
else
@@ -315,10 +315,10 @@
editors = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'edit' }).pluck(:role_id)
Caboose::Page.update_authorized_for_action(page.id, 'view', viewers)
Caboose::Page.update_authorized_for_action(page.id, 'edit', editors)
# Send back the response
- resp.redirect = "/admin/pages/#{page.id}/edit"
+ resp.redirect = "/admin/pages/#{page.id}"
render json: resp
end
# PUT /admin/pages/:id
def admin_update