From 61799bc63f9ff38d94a9814d4901772f9625a9cc Mon Sep 17 00:00:00 2001
From: Jacques Distler
Date: Sat, 6 Dec 2008 06:06:46 -0600
Subject: [PATCH] Delete_Web
Add a user interface to delete a Web.
---
app/controllers/admin_controller.rb | 17 +++++++++++++++++
app/views/admin/edit_web.rhtml | 13 +++++++++++++
2 files changed, 30 insertions(+)
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index e013853f..34c5231a 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -103,5 +103,22 @@ class AdminController < ApplicationController
redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web'
end
end
+
+ def delete_web
+ unless (request.post? || ENV["RAILS_ENV"] == "test")
+ headers['Allow'] = 'POST'
+ render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error')
+ return
+ end
+ if wiki.authenticate(params['system_password_delete_web'])
+ @web.remove_pages(@web.select_all)
+ wiki.delete_web(@web_name)
+ flash[:info] = "Web \"#{@web_name}\" has been deleted."
+ redirect_to :controller => 'wiki', :action => 'web_list'
+ else
+ flash[:error] = password_error(params['system_password_delete_web'])
+ redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web'
+ end
+ end
end
diff --git a/app/views/admin/edit_web.rhtml b/app/views/admin/edit_web.rhtml
index 64d0f90f..393f1d1b 100644
--- a/app/views/admin/edit_web.rhtml
+++ b/app/views/admin/edit_web.rhtml
@@ -125,4 +125,17 @@
<% end %>
+<% form_tag({:controller => 'admin', :web => @web.address, :action => 'delete_web'},
+ { :id => 'delete_web',
+ :onsubmit => "return checkSystemPassword(document.getElementById('system_password_delete_web').value)",
+ 'accept-charset' => 'utf-8' }) do
+%>
+
+ Delete this Web, and all its pages.
+
+ and
+
+
+<% end %>
+
<%= javascript_include_tag 'edit_web' %>