diff options
| author | hukl <contact@smyck.org> | 2009-05-01 18:14:59 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-05-01 18:14:59 +0200 |
| commit | 8d084cf690a78eae0df5c9e13b34ed3c08f6e161 (patch) | |
| tree | 7df74078236c5533ada0a4e8f6b8a5515128172d | |
| parent | e9064192e9a38dd1ec8314d99bf3cc553e38b30c (diff) | |
introducing the restore revision functionality
| -rw-r--r-- | app/controllers/revisions_controller.rb | 6 | ||||
| -rw-r--r-- | app/views/revisions/show.html.erb | 14 | ||||
| -rw-r--r-- | config/routes.rb | 2 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 4 |
4 files changed, 23 insertions, 3 deletions
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb index 7ae22f8..e2c0432 100644 --- a/app/controllers/revisions_controller.rb +++ b/app/controllers/revisions_controller.rb | |||
| @@ -32,4 +32,10 @@ class RevisionsController < ApplicationController | |||
| 32 | @node = Node.find(params[:id]) | 32 | @node = Node.find(params[:id]) |
| 33 | end | 33 | end |
| 34 | 34 | ||
| 35 | def restore | ||
| 36 | page = Page.find(params[:id]) | ||
| 37 | page.node.restore_revision! page.revision | ||
| 38 | flash[:notice] = "Revision #{page.revision} restored" | ||
| 39 | redirect_to :back | ||
| 40 | end | ||
| 35 | end | 41 | end |
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb index 2a4a9a1..ebda18d 100644 --- a/app/views/revisions/show.html.erb +++ b/app/views/revisions/show.html.erb | |||
| @@ -23,11 +23,21 @@ | |||
| 23 | <td class="title"><%= page.title %></td> | 23 | <td class="title"><%= page.title %></td> |
| 24 | <td class="user"><%= page.user.try(:login) %></td> | 24 | <td class="user"><%= page.user.try(:login) %></td> |
| 25 | <td class="date"><%= page.updated_at %></td> | 25 | <td class="date"><%= page.updated_at %></td> |
| 26 | <td class="actions"><%= link_to 'show', node_path(page.node) %></td> | 26 | <td> |
| 27 | <%= link_to 'show', node_path(page.node) %> | ||
| 28 | </td> | ||
| 29 | <td> | ||
| 30 | <%= link_to( | ||
| 31 | 'restore', | ||
| 32 | restore_revision_path(page), | ||
| 33 | :method => :put, | ||
| 34 | :confirm => "Restore this revision?" | ||
| 35 | ) %> | ||
| 36 | </td> | ||
| 27 | </tr> | 37 | </tr> |
| 28 | <% end %> | 38 | <% end %> |
| 29 | <tr class="no_hover"> | 39 | <tr class="no_hover"> |
| 30 | <td colspan="7" class="right"><%= submit_tag 'Diff revisions' %></td> | 40 | <td colspan="8" class="right"><%= submit_tag 'Diff revisions' %></td> |
| 31 | </tr> | 41 | </tr> |
| 32 | </table> | 42 | </table> |
| 33 | 43 | ||
diff --git a/config/routes.rb b/config/routes.rb index e96ea13..bf4ba10 100644 --- a/config/routes.rb +++ b/config/routes.rb | |||
| @@ -14,7 +14,7 @@ ActionController::Routing::Routes.draw do |map| | |||
| 14 | 14 | ||
| 15 | map.resources :occurrences | 15 | map.resources :occurrences |
| 16 | map.resources :events | 16 | map.resources :events |
| 17 | map.resources :revisions, :member => {:diff => :post} | 17 | map.resources :revisions, :member => {:diff => :post, :restore => :put} |
| 18 | map.resources :pages | 18 | map.resources :pages |
| 19 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} | 19 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} |
| 20 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' | 20 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' |
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 52d657e..982a231 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -159,6 +159,10 @@ table#revisions td.title { | |||
| 159 | width: 450px; | 159 | width: 450px; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | table#revisions td.date { | ||
| 163 | width: 175px; | ||
| 164 | } | ||
| 165 | |||
| 162 | table#revisions tr.header:hover { | 166 | table#revisions tr.header:hover { |
| 163 | background-color: #ffffff; | 167 | background-color: #ffffff; |
| 164 | } | 168 | } |
