##// END OF EJS Templates
Added the ability to destroy wiki pages (content and its history are deleted from the database)....
Jean-Philippe Lang -
r537:6446c312beab
parent child
Show More
@@ -0,0 +1,9
1 class AddWikiDestroyPagePermission < ActiveRecord::Migration
2 def self.up
3 Permission.create :controller => 'wiki', :action => 'destroy', :description => 'button_delete', :sort => 1740, :is_public => false, :mail_option => 0, :mail_enabled => 0
4 end
5
6 def self.down
7 Permission.find_by_controller_and_action('wiki', 'destroy').destroy
8 end
9 end
@@ -18,6 +18,9
18 18 class WikiController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_wiki, :check_project_privacy, :except => [:preview]
21 before_filter :authorize, :only => :destroy
22
23 verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
21 24
22 25 # display a page (in editing mode if it doesn't exist)
23 26 def index
@@ -73,6 +76,13 class WikiController < ApplicationController
73 76 :order => 'version DESC'
74 77 end
75 78
79 # remove a wiki page and its history
80 def destroy
81 @page = @wiki.find_page(params[:page])
82 @page.destroy if @page
83 redirect_to :action => 'special', :id => @project, :page => 'Page_index'
84 end
85
76 86 # display special pages
77 87 def special
78 88 page_title = params[:page].downcase
@@ -32,6 +32,7 class Permission < ActiveRecord::Base
32 32 1300 => :label_attachment_plural,
33 33 1400 => :label_repository,
34 34 1500 => :label_time_tracking,
35 1700 => :label_wiki_page_plural,
35 36 2000 => :label_board_plural
36 37 }.freeze
37 38
@@ -1,5 +1,6
1 1 <div class="contextual">
2 2 <%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %>
3 <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
3 4 <%= link_to(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
4 5 <%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
5 6 <%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
@@ -346,6 +346,7 label_all_words: Всички думи
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki редакция
348 348 label_wiki_edit_plural: Wiki редакции
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Индекс
350 351 label_current_version: Текуща версия
351 352 label_preview: Преглед
@@ -346,6 +346,7 label_all_words: Alle Wörter
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki Bearbeitung
348 348 label_wiki_edit_plural: Wiki Bearbeitungen
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Index
350 351 label_current_version: Gegenwärtige Version
351 352 label_preview: Vorschau
@@ -346,6 +346,7 label_all_words: All words
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki edit
348 348 label_wiki_edit_plural: Wiki edits
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Index
350 351 label_current_version: Current version
351 352 label_preview: Preview
@@ -346,6 +346,7 label_all_words: Todas las palabras
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki edit
348 348 label_wiki_edit_plural: Wiki edits
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Índice
350 351 label_current_version: Versión actual
351 352 label_preview: Previo
@@ -346,6 +346,7 label_all_words: Tous les mots
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Révision wiki
348 348 label_wiki_edit_plural: Révisions wiki
349 label_wiki_page_plural: Pages wiki
349 350 label_page_index: Index
350 351 label_current_version: Version actuelle
351 352 label_preview: Prévisualisation
@@ -346,6 +346,7 label_all_words: Tutte le parole
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Modifica Wiki
348 348 label_wiki_edit_plural: Modfiche wiki
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Indice
350 351 label_current_version: Versione corrente
351 352 label_preview: Anteprima
@@ -347,6 +347,7 label_all_words: すべての単語
347 347 label_wiki: Wiki
348 348 label_wiki_edit: Wiki編集
349 349 label_wiki_edit_plural: Wiki編集
350 label_wiki_page_plural: Wiki pages
350 351 label_page_index: 索引
351 352 label_current_version: 最新版
352 353 label_preview: プレビュー
@@ -346,6 +346,7 label_all_words: Alle woorden
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki edit
348 348 label_wiki_edit_plural: Wiki edits
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Index
350 351 label_current_version: Huidige versie
351 352 label_preview: Testweergave
@@ -346,6 +346,7 label_all_words: Todas as palavras
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki edit
348 348 label_wiki_edit_plural: Wiki edits
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Index
350 351 label_current_version: Versao atual
351 352 label_preview: Previa
@@ -346,6 +346,7 label_all_words: Todas as palavras
346 346 label_wiki: Wiki
347 347 label_wiki_edit: Wiki edit
348 348 label_wiki_edit_plural: Wiki edits
349 label_wiki_page_plural: Wiki pages
349 350 label_page_index: Index
350 351 label_current_version: Versão atual
351 352 label_preview: Prévia
@@ -349,6 +349,7 label_all_words: 所有单词
349 349 label_wiki: Wiki
350 350 label_wiki_edit: Wiki edit
351 351 label_wiki_edit_plural: Wiki edits
352 label_wiki_page_plural: Wiki pages
352 353 label_page_index: 索引
353 354 label_current_version: 当前版本
354 355 label_preview: 预览
@@ -18,7 +18,7
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19
20 20 class WikiPageTest < Test::Unit::TestCase
21 fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
21 fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
22 22
23 23 def setup
24 24 @wiki = Wiki.find(1)
@@ -47,4 +47,13 class WikiPageTest < Test::Unit::TestCase
47 47 assert_kind_of WikiPage, page
48 48 assert page.new_record?
49 49 end
50
51 def test_destroy
52 page = WikiPage.find(1)
53 page.destroy
54 assert_nil WikiPage.find_by_id(1)
55 # make sure that page content and its history are deleted
56 assert WikiContent.find_all_by_page_id(1).empty?
57 assert WikiContent.versioned_class.find_all_by_page_id(1).empty?
58 end
50 59 end
General Comments 0
You need to be logged in to leave comments. Login now