From 113449eacba67625004b14081f4cc0cc3b984553 Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 2 Mar 2009 17:22:48 +0100 Subject: added unlock functionality. not yet hooked up with permissions though. anybody can unlock. put a confirmation in front of it. destroy has to be confirmed as well --- app/controllers/nodes_controller.rb | 17 ++++++++++++++++- app/views/nodes/index.html.erb | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index a403b95..81ead62 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -7,7 +7,8 @@ class NodesController < ApplicationController :edit, :update, :destroy, - :publish + :publish, + :unlock ] def index @@ -67,6 +68,20 @@ class NodesController < ApplicationController redirect_to node_path end + def unlock + # TODO that actually has to be implemented in the model, once we have + # permissions + if draft = @node.draft + draft.user = nil + draft.save + flash[:notice] = "Node unlocked" + else + flash[:notice] = "Cannot unlock" + end + + redirect_to nodes_path + end + def move_to parent = Node.find params[:parent_id] @node.move_to_child_of parent diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb index 1429d1a..833ffed 100644 --- a/app/views/nodes/index.html.erb +++ b/app/views/nodes/index.html.erb @@ -23,7 +23,8 @@ <%= link_to 'Show', node_path(node) %> <%= link_to 'Edit', edit_node_path(node) %> - <%= link_to 'Destroy', node, :method => :delete %> + <%= link_to 'Destroy', node, :method => :delete, :confirm => "Are you sure you want to delete this node?" %> + <%= link_to 'Unlock', unlock_node_path(node), :method => :put, :confirm => "Are you sure you want to unlock?" %> <%= "#{node.draft.user.login}" if node.draft && node.draft.user %> -- cgit v1.3