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
|
class WikiController < ApplicationController
|
||||||
default_search_scope :wiki_pages
|
default_search_scope :wiki_pages
|
||||||
before_filter :find_wiki, :authorize
|
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]
|
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
|
helper :attachments
|
||||||
include AttachmentsHelper
|
include AttachmentsHelper
|
||||||
helper :watchers
|
helper :watchers
|
||||||
@ -56,8 +55,6 @@ class WikiController < ApplicationController
|
|||||||
|
|
||||||
# display a page (in editing mode if it doesn't exist)
|
# display a page (in editing mode if it doesn't exist)
|
||||||
def show
|
def show
|
||||||
page_title = params[:id]
|
|
||||||
@page = @wiki.find_or_new_page(page_title)
|
|
||||||
if @page.new_record?
|
if @page.new_record?
|
||||||
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
|
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
|
||||||
edit
|
edit
|
||||||
@ -89,7 +86,6 @@ class WikiController < ApplicationController
|
|||||||
|
|
||||||
# edit an existing page or a new one
|
# edit an existing page or a new one
|
||||||
def edit
|
def edit
|
||||||
@page = @wiki.find_or_new_page(params[:id])
|
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
@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 }
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
# Creates a new page or updates an existing one
|
# Creates a new page or updates an existing one
|
||||||
def update
|
def update
|
||||||
@page = @wiki.find_or_new_page(params[:id])
|
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||||
|
|
||||||
@ -151,6 +146,7 @@ class WikiController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => :protect, :redirect_to => { :action => :show }
|
||||||
def protect
|
def protect
|
||||||
@page.update_attribute :protected, params[:protected]
|
@page.update_attribute :protected, params[:protected]
|
||||||
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
@ -250,6 +246,11 @@ private
|
|||||||
render_404
|
render_404
|
||||||
end
|
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
|
# Finds the requested page and returns a 404 error if it doesn't exist
|
||||||
def find_existing_page
|
def find_existing_page
|
||||||
@page = @wiki.find_page(params[:id])
|
@page = @wiki.find_page(params[:id])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user