Added the ability to destroy wiki pages (content and its history are deleted from the database).
This permission has to be explicitly given (Roles & Permissions -> Wiki pages/Delete). git-svn-id: http://redmine.rubyforge.org/svn/trunk@540 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4a524ff911
commit
6446c312be
|
@ -18,6 +18,9 @@
|
|||
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
|
||||
|
@ -73,6 +76,13 @@ class WikiController < ApplicationController
|
|||
: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
|
||||
page_title = params[:page].downcase
|
||||
|
|
|
@ -32,6 +32,7 @@ class Permission < ActiveRecord::Base
|
|||
1300 => :label_attachment_plural,
|
||||
1400 => :label_repository,
|
||||
1500 => :label_time_tracking,
|
||||
1700 => :label_wiki_page_plural,
|
||||
2000 => :label_board_plural
|
||||
}.freeze
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<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') %>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
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
|
|
@ -346,6 +346,7 @@ label_all_words: Всички думи
|
|||
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: Преглед
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Alle Wörter
|
|||
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
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: All words
|
|||
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
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Todas las palabras
|
|||
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
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Tous les mots
|
|||
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
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Tutte le parole
|
|||
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
|
||||
|
|
|
@ -347,6 +347,7 @@ label_all_words: すべての単語
|
|||
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: プレビュー
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Alle woorden
|
|||
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
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Todas as palavras
|
|||
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: Versao atual
|
||||
label_preview: Previa
|
||||
|
|
|
@ -346,6 +346,7 @@ label_all_words: Todas as palavras
|
|||
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
|
||||
|
|
|
@ -349,6 +349,7 @@ label_all_words: 所有单词
|
|||
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: 预览
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
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)
|
||||
|
@ -47,4 +47,13 @@ class WikiPageTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue