From 443947a319692e0462024c99f06e4d18ab5f0344 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 17 Oct 2009 23:32:18 +0200 Subject: changed some node related methods and implementation of unlock --- app/controllers/nodes_controller.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'app/controllers/nodes_controller.rb') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 20aea5a..4f72744 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -43,7 +43,8 @@ class NodesController < ApplicationController end def show - @page = Node.find(params[:id]).pages.last + node = Node.find(params[:id]) + @page = node.draft || node.head end def edit @@ -51,7 +52,11 @@ class NodesController < ApplicationController @draft = @node.find_or_create_draft( current_user ) rescue LockedByAnotherUser => e flash[:error] = e.message - redirect_to :back + if request.referer + redirect_to :back + else + redirect_to node_path(@node) + end end end @@ -81,22 +86,13 @@ class NodesController < ApplicationController end def unlock - # TODO that actually has to be implemented in the model, once we have - # permissions - if @node.lock_owner - @node.unlock! + if @node.unlock! flash[:notice] = "Node unlocked" else - flash[:notice] = "Cannot unlock" + flash[:notice] = "Already unlocked" end - redirect_to :back - end - - def move_to - parent = Node.find params[:parent_id] - @node.move_to_child_of parent - redirect_to(@node) + redirect_to node_path(@node) end private -- cgit v1.3