merged edit_web and update_web into one action
This commit is contained in:
parent
9cfa77dca2
commit
09cfb5635c
6 changed files with 33 additions and 28 deletions
|
@ -44,26 +44,32 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
def edit_web
|
||||
# to template
|
||||
end
|
||||
|
||||
def update_web
|
||||
if wiki.authenticate(@params['system_password'])
|
||||
wiki.update_web(
|
||||
@web.address, @params['address'], @params['name'],
|
||||
@params['markup'].intern,
|
||||
@params['color'], @params['additional_style'],
|
||||
@params['safe_mode'] ? true : false,
|
||||
@params['password'].empty? ? nil : @params['password'],
|
||||
@params['published'] ? true : false,
|
||||
@params['brackets_only'] ? true : false,
|
||||
@params['count_pages'] ? true : false,
|
||||
@params['allow_uploads'] ? true : false,
|
||||
@params['max_upload_size']
|
||||
)
|
||||
redirect_show('HomePage', @params['address'])
|
||||
if @params['system_password']
|
||||
# form submitted
|
||||
if wiki.authenticate(@params['system_password'])
|
||||
wiki.edit_web(
|
||||
@web.address, @params['address'], @params['name'],
|
||||
@params['markup'].intern,
|
||||
@params['color'], @params['additional_style'],
|
||||
@params['safe_mode'] ? true : false,
|
||||
@params['password'].empty? ? nil : @params['password'],
|
||||
@params['published'] ? true : false,
|
||||
@params['brackets_only'] ? true : false,
|
||||
@params['count_pages'] ? true : false,
|
||||
@params['allow_uploads'] ? true : false,
|
||||
@params['max_upload_size']
|
||||
)
|
||||
redirect_show('HomePage', @params['address'])
|
||||
else
|
||||
if @params['system_password'].empty?
|
||||
flash[:error] = 'Please enter the system password'
|
||||
else
|
||||
flash[:error] = 'You entered a wrong system password. Please enter the right one'
|
||||
end
|
||||
# and re-render the same template again
|
||||
end
|
||||
else
|
||||
redirect_show('HomePage')
|
||||
# no form submitted - go to template
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ module AbstractWikiService
|
|||
not (@webs.empty?)
|
||||
end
|
||||
|
||||
def update_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false,
|
||||
def edit_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false,
|
||||
password = nil, published = false, brackets_only = false, count_pages = false,
|
||||
allow_uploads = true, max_upload_size = nil)
|
||||
if old_address != new_address
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% @title = "Edit Web" %>
|
||||
|
||||
<form action="../update_web" id="setup" method="post" onSubmit="cleanAddress(); return validateSetup()">
|
||||
<form action="edit_web" id="setup" method="post" onSubmit="cleanAddress(); return validateSetup()">
|
||||
<h2 style="margin-bottom: 3px">Name and address</h2>
|
||||
<div class="help">
|
||||
The name of the web is included in the title on all pages.
|
||||
|
@ -109,7 +109,7 @@
|
|||
<br/>
|
||||
<h1>Other administrative tasks</h1>
|
||||
|
||||
<form action="../remove_orphaned_pages" id="remove_orphaned_pages" method="post">
|
||||
<form action="remove_orphaned_pages" id="remove_orphaned_pages" method="post">
|
||||
<p align="right">
|
||||
<small>
|
||||
Clean up by entering system password
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<div class="navigation">
|
||||
<% if @page.name == "HomePage" %>
|
||||
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit Page</a>
|
||||
| <a href="../edit_web/" class="navlink">Edit Web</a>
|
||||
| <a href="../edit_web" class="navlink">Edit Web</a>
|
||||
<% else %>
|
||||
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit</a>
|
||||
<% end %>
|
||||
|
|
|
@ -68,7 +68,6 @@ class DispatchServlet
|
|||
'file' => 'file',
|
||||
'import' => 'file',
|
||||
'pic' => 'file',
|
||||
'update_web' => 'admin'
|
||||
}
|
||||
|
||||
def self.map_to_controller(action)
|
||||
|
|
|
@ -112,10 +112,10 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
|
||||
def test_update_web
|
||||
def test_edit_web
|
||||
@wiki.system[:password] = 'pswd'
|
||||
|
||||
process('update_web', 'system_password' => 'pswd',
|
||||
process('edit_web', 'system_password' => 'pswd',
|
||||
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
||||
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
||||
'safe_mode' => 'on', 'password' => 'new_password', 'published' => 'on',
|
||||
|
@ -136,10 +136,10 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
assert_equal 300, @web.max_upload_size
|
||||
end
|
||||
|
||||
def test_update_web_opposite_values
|
||||
def test_edit_web_opposite_values
|
||||
@wiki.system[:password] = 'pswd'
|
||||
|
||||
process('update_web', 'system_password' => 'pswd',
|
||||
process('edit_web', 'system_password' => 'pswd',
|
||||
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
||||
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
||||
'password' => 'new_password')
|
||||
|
|
Loading…
Reference in a new issue