destroy wiki menu item when corresponding page is destroyed

pull/41/head
Romano Licker 12 years ago
parent 065406a387
commit f7b67bcd87
  1. 6
      app/models/wiki_page.rb

@ -47,12 +47,18 @@ class WikiPage < ActiveRecord::Base
# Wiki pages that are protected by default
DEFAULT_PROTECTED_PAGES = %w(sidebar)
after_destroy :delete_wiki_menu_item
def after_initialize
if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
self.protected = true
end
end
def delete_wiki_menu_item
self.menu_item.destroy if self.menu_item
end
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
end

Loading…
Cancel
Save