Clean Deletions

Deleting a page removes all revisions of that page.
Deleting a Web removes all pages (and all revisions thereof)
  and all wiki_files belonging to that Web.
This commit is contained in:
Jacques Distler 2008-12-28 21:36:37 -06:00
parent c3c33b68dd
commit 397859ba8a
3 changed files with 3 additions and 4 deletions

View file

@ -112,7 +112,6 @@ class AdminController < ApplicationController
def delete_web def delete_web
return unless is_post return unless is_post
if wiki.authenticate(params['system_password_delete_web']) if wiki.authenticate(params['system_password_delete_web'])
@web.remove_pages(@web.select_all)
wiki.delete_web(@web_name) wiki.delete_web(@web_name)
flash[:info] = "Web \"#{@web_name}\" has been deleted." flash[:info] = "Web \"#{@web_name}\" has been deleted."
redirect_to :controller => 'wiki', :action => 'web_list' redirect_to :controller => 'wiki', :action => 'web_list'

View file

@ -1,6 +1,6 @@
class Page < ActiveRecord::Base class Page < ActiveRecord::Base
belongs_to :web belongs_to :web
has_many :revisions, :order => 'id' has_many :revisions, :order => 'id', :dependent => :destroy
has_many :wiki_references, :order => 'referenced_name' has_many :wiki_references, :order => 'referenced_name'
has_one :current_revision, :class_name => 'Revision', :order => 'id DESC' has_one :current_revision, :class_name => 'Revision', :order => 'id DESC'

View file

@ -1,6 +1,6 @@
class Web < ActiveRecord::Base class Web < ActiveRecord::Base
has_many :pages has_many :pages, :dependent => :destroy
has_many :wiki_files has_many :wiki_files, :dependent => :destroy
def wiki def wiki
Wiki.new Wiki.new