class WikiController < ApplicationController
layout 'base'
before_filter :find_wiki, :check_project_privacy, :except => [:preview]
-
+ before_filter :authorize, :only => :destroy
+
+ verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
+
# display a page (in editing mode if it doesn't exist)
def index
page_title = params[:page]
:select => "id, author_id, comments, updated_on, version",
:order => 'version DESC'
end
+
+ # remove a wiki page and its history
+ def destroy
+ @page = @wiki.find_page(params[:page])
+ @page.destroy if @page
+ redirect_to :action => 'special', :id => @project, :page => 'Page_index'
+ end
# display special pages
def special
1300 => :label_attachment_plural,
1400 => :label_repository,
1500 => :label_time_tracking,
+ 1700 => :label_wiki_page_plural,
2000 => :label_board_plural
}.freeze
<div class="contextual">
<%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %>
+<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
<%= link_to(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
--- /dev/null
+class AddWikiDestroyPagePermission < ActiveRecord::Migration
+ def self.up
+ Permission.create :controller => 'wiki', :action => 'destroy', :description => 'button_delete', :sort => 1740, :is_public => false, :mail_option => 0, :mail_enabled => 0
+ end
+
+ def self.down
+ Permission.find_by_controller_and_action('wiki', 'destroy').destroy
+ end
+end
label_wiki: Wiki
label_wiki_edit: Wiki редакция
label_wiki_edit_plural: Wiki редакции
+label_wiki_page_plural: Wiki pages
label_page_index: Индекс
label_current_version: Текуща версия
label_preview: Преглед
label_wiki: Wiki
label_wiki_edit: Wiki Bearbeitung
label_wiki_edit_plural: Wiki Bearbeitungen
+label_wiki_page_plural: Wiki pages
label_page_index: Index
label_current_version: Gegenwärtige Version
label_preview: Vorschau
label_wiki: Wiki
label_wiki_edit: Wiki edit
label_wiki_edit_plural: Wiki edits
+label_wiki_page_plural: Wiki pages
label_page_index: Index
label_current_version: Current version
label_preview: Preview
label_wiki: Wiki
label_wiki_edit: Wiki edit
label_wiki_edit_plural: Wiki edits
+label_wiki_page_plural: Wiki pages
label_page_index: Índice
label_current_version: Versión actual
label_preview: Previo
label_wiki: Wiki
label_wiki_edit: Révision wiki
label_wiki_edit_plural: Révisions wiki
+label_wiki_page_plural: Pages wiki
label_page_index: Index
label_current_version: Version actuelle
label_preview: Prévisualisation
label_wiki: Wiki
label_wiki_edit: Modifica Wiki
label_wiki_edit_plural: Modfiche wiki
+label_wiki_page_plural: Wiki pages
label_page_index: Indice
label_current_version: Versione corrente
label_preview: Anteprima
label_wiki: Wiki
label_wiki_edit: Wiki編集
label_wiki_edit_plural: Wiki編集
+label_wiki_page_plural: Wiki pages
label_page_index: 索引
label_current_version: 最新版
label_preview: プレビュー
label_wiki: Wiki
label_wiki_edit: Wiki edit
label_wiki_edit_plural: Wiki edits
+label_wiki_page_plural: Wiki pages
label_page_index: Index
label_current_version: Huidige versie
label_preview: Testweergave
label_wiki: Wiki\r
label_wiki_edit: Wiki edit\r
label_wiki_edit_plural: Wiki edits\r
+label_wiki_page_plural: Wiki pages\r
label_page_index: Index\r
label_current_version: Versao atual\r
label_preview: Previa\r
label_wiki: Wiki
label_wiki_edit: Wiki edit
label_wiki_edit_plural: Wiki edits
+label_wiki_page_plural: Wiki pages
label_page_index: Index
label_current_version: Versão atual
label_preview: Prévia
label_wiki: Wiki
label_wiki_edit: Wiki edit
label_wiki_edit_plural: Wiki edits
+label_wiki_page_plural: Wiki pages
label_page_index: 索引
label_current_version: 当前版本
label_preview: 预览
require File.dirname(__FILE__) + '/../test_helper'
class WikiPageTest < Test::Unit::TestCase
- fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
+ fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
def setup
@wiki = Wiki.find(1)
assert_kind_of WikiPage, page
assert page.new_record?
end
+
+ def test_destroy
+ page = WikiPage.find(1)
+ page.destroy
+ assert_nil WikiPage.find_by_id(1)
+ # make sure that page content and its history are deleted
+ assert WikiContent.find_all_by_page_id(1).empty?
+ assert WikiContent.versioned_class.find_all_by_page_id(1).empty?
+ end
end