Delete_Web

Add a user interface to delete a Web.
This commit is contained in:
Jacques Distler 2008-12-06 06:06:46 -06:00
parent 7e66134e2f
commit 61799bc63f
2 changed files with 30 additions and 0 deletions

View file

@ -104,4 +104,21 @@ class AdminController < ApplicationController
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

View file

@ -125,4 +125,17 @@
</p>
<% 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
%>
<p style="text-align:right;font-size:.85em;">
Delete this Web, and all its pages.
<input type="password" id="system_password_delete_web" class="disableAutoComplete" name="system_password_delete_web" />
and
<input type="submit" value="Delete Web" />
</p>
<% end %>
<%= javascript_include_tag 'edit_web' %>