Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5422 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ae16fb3e5f
commit
6db0e8dcef
|
@ -34,10 +34,9 @@ require 'diff'
|
|||
class WikiController < ApplicationController
|
||||
default_search_scope :wiki_pages
|
||||
before_filter :find_wiki, :authorize
|
||||
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
|
||||
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
|
||||
|
||||
verify :method => :post, :only => [:protect], :redirect_to => { :action => :show }
|
||||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
helper :watchers
|
||||
|
@ -56,8 +55,6 @@ class WikiController < ApplicationController
|
|||
|
||||
# display a page (in editing mode if it doesn't exist)
|
||||
def show
|
||||
page_title = params[:id]
|
||||
@page = @wiki.find_or_new_page(page_title)
|
||||
if @page.new_record?
|
||||
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
|
||||
edit
|
||||
|
@ -89,7 +86,6 @@ class WikiController < ApplicationController
|
|||
|
||||
# edit an existing page or a new one
|
||||
def edit
|
||||
@page = @wiki.find_or_new_page(params[:id])
|
||||
return render_403 unless editable?
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
|
||||
|
@ -105,7 +101,6 @@ class WikiController < ApplicationController
|
|||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||
# Creates a new page or updates an existing one
|
||||
def update
|
||||
@page = @wiki.find_or_new_page(params[:id])
|
||||
return render_403 unless editable?
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
|
||||
|
@ -151,6 +146,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
verify :method => :post, :only => :protect, :redirect_to => { :action => :show }
|
||||
def protect
|
||||
@page.update_attribute :protected, params[:protected]
|
||||
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||
|
@ -250,6 +246,11 @@ private
|
|||
render_404
|
||||
end
|
||||
|
||||
# Finds the requested page or a new page if it doesn't exist
|
||||
def find_existing_or_new_page
|
||||
@page = @wiki.find_or_new_page(params[:id])
|
||||
end
|
||||
|
||||
# Finds the requested page and returns a 404 error if it doesn't exist
|
||||
def find_existing_page
|
||||
@page = @wiki.find_page(params[:id])
|
||||
|
|
Loading…
Reference in New Issue