summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-10-17 23:32:18 +0200
committerhukl <contact@smyck.org>2009-10-17 23:32:18 +0200
commit443947a319692e0462024c99f06e4d18ab5f0344 (patch)
tree652caf728cb07d0eebb3777482f8c1408a32cac0
parentc7c4b007621fd28c88b65db5fd3296ef730097d9 (diff)
changed some node related methods and implementation of unlock
-rw-r--r--app/controllers/nodes_controller.rb24
-rw-r--r--app/helpers/link_helper.rb11
-rw-r--r--app/views/nodes/index.html.erb6
-rw-r--r--app/views/nodes/show.html.erb4
-rw-r--r--public/stylesheets/admin.css2
5 files changed, 26 insertions, 21 deletions
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
43 end 43 end
44 44
45 def show 45 def show
46 @page = Node.find(params[:id]).pages.last 46 node = Node.find(params[:id])
47 @page = node.draft || node.head
47 end 48 end
48 49
49 def edit 50 def edit
@@ -51,7 +52,11 @@ class NodesController < ApplicationController
51 @draft = @node.find_or_create_draft( current_user ) 52 @draft = @node.find_or_create_draft( current_user )
52 rescue LockedByAnotherUser => e 53 rescue LockedByAnotherUser => e
53 flash[:error] = e.message 54 flash[:error] = e.message
54 redirect_to :back 55 if request.referer
56 redirect_to :back
57 else
58 redirect_to node_path(@node)
59 end
55 end 60 end
56 end 61 end
57 62
@@ -81,22 +86,13 @@ class NodesController < ApplicationController
81 end 86 end
82 87
83 def unlock 88 def unlock
84 # TODO that actually has to be implemented in the model, once we have 89 if @node.unlock!
85 # permissions
86 if @node.lock_owner
87 @node.unlock!
88 flash[:notice] = "Node unlocked" 90 flash[:notice] = "Node unlocked"
89 else 91 else
90 flash[:notice] = "Cannot unlock" 92 flash[:notice] = "Already unlocked"
91 end 93 end
92 94
93 redirect_to :back 95 redirect_to node_path(@node)
94 end
95
96 def move_to
97 parent = Node.find params[:parent_id]
98 @node.move_to_child_of parent
99 redirect_to(@node)
100 end 96 end
101 97
102 private 98 private
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
index 65137ee..b77a1df 100644
--- a/app/helpers/link_helper.rb
+++ b/app/helpers/link_helper.rb
@@ -40,4 +40,15 @@ module LinkHelper
40 return :class => "selected" 40 return :class => "selected"
41 end 41 end
42 end 42 end
43
44 def unlock_link
45 message = "Are you sure you want to unlock?\n" +
46 "Locked by #{@node.lock_owner.login}\n" +
47 "Last modified #{@page.updated_at.to_s(:db)}"
48
49 link_to(
50 'Unlock', unlock_node_path(@node), :method => :put, :confirm => message
51 )
52 end
53
43end \ No newline at end of file 54end \ No newline at end of file
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb
index d78a997..46c58f6 100644
--- a/app/views/nodes/index.html.erb
+++ b/app/views/nodes/index.html.erb
@@ -20,10 +20,8 @@
20 <p><%= link_to_path(node.unique_name, node.unique_name) %></p> 20 <p><%= link_to_path(node.unique_name, node.unique_name) %></p>
21 </td> 21 </td>
22 <td class="actions"> 22 <td class="actions">
23 <%= link_to 'show', node_path(node) %> 23 <%= link_to 'show', node_path(node) %>
24 <%= link_to 'Revisions', node_revisions_path(node) %> 24 <%= link_to 'Revisions', node_revisions_path(node) %>
25 <%# link_to 'Destroy', node, :method => :delete, :confirm => "Are you sure you want to delete this node?" %>
26 <%= link_to 'Unlock', unlock_node_path(node), :method => :put, :confirm => "Are you sure you want to unlock?" %>
27 </td> 25 </td>
28 <td> 26 <td>
29 <%= node.lock_owner.login if node.lock_owner %> 27 <%= node.lock_owner.login if node.lock_owner %>
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb
index 99fb264..87f65f5 100644
--- a/app/views/nodes/show.html.erb
+++ b/app/views/nodes/show.html.erb
@@ -2,7 +2,7 @@
2 <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %> 2 <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %>
3 <%= link_to 'Preview', preview_page_path(@page) %> 3 <%= link_to 'Preview', preview_page_path(@page) %>
4 <%= link_to 'Revisions', node_revisions_path(@node) %> 4 <%= link_to 'Revisions', node_revisions_path(@node) %>
5 <%= link_to 'Unlock', unlock_node_path(@node), :method => :put, :confirm => "Are you sure you want to unlock?" %> 5 <%= unlock_link if @node.locked? %>
6<% end %> 6<% end %>
7 7
8 8
@@ -19,7 +19,7 @@
19 <% if @page.node.locked? %> 19 <% if @page.node.locked? %>
20 <tr> 20 <tr>
21 <td class="description">Locked by</td> 21 <td class="description">Locked by</td>
22 <td><%= @page.node.lock_owner.login %></td> 22 <td><span class="warning"><%= @page.node.lock_owner.login %></span></td>
23 </tr> 23 </tr>
24 <% end %> 24 <% end %>
25 <tr> 25 <tr>
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css
index 1822ed1..6fa5b59 100644
--- a/public/stylesheets/admin.css
+++ b/public/stylesheets/admin.css
@@ -48,7 +48,7 @@ th {
48 width: 12px; 48 width: 12px;
49} 49}
50 50
51span#flash_error { 51span#flash_error, span.warning {
52 color: #ffffff; 52 color: #ffffff;
53 letter-spacing: 1px; 53 letter-spacing: 1px;
54 background-color: #ff9600; 54 background-color: #ff9600;