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,12 +44,10 @@ class AdminController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_web
|
def edit_web
|
||||||
# to template
|
if @params['system_password']
|
||||||
end
|
# form submitted
|
||||||
|
|
||||||
def update_web
|
|
||||||
if wiki.authenticate(@params['system_password'])
|
if wiki.authenticate(@params['system_password'])
|
||||||
wiki.update_web(
|
wiki.edit_web(
|
||||||
@web.address, @params['address'], @params['name'],
|
@web.address, @params['address'], @params['name'],
|
||||||
@params['markup'].intern,
|
@params['markup'].intern,
|
||||||
@params['color'], @params['additional_style'],
|
@params['color'], @params['additional_style'],
|
||||||
|
@ -63,7 +61,15 @@ class AdminController < ApplicationController
|
||||||
)
|
)
|
||||||
redirect_show('HomePage', @params['address'])
|
redirect_show('HomePage', @params['address'])
|
||||||
else
|
else
|
||||||
redirect_show('HomePage')
|
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
|
||||||
|
# no form submitted - go to template
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ module AbstractWikiService
|
||||||
not (@webs.empty?)
|
not (@webs.empty?)
|
||||||
end
|
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,
|
password = nil, published = false, brackets_only = false, count_pages = false,
|
||||||
allow_uploads = true, max_upload_size = nil)
|
allow_uploads = true, max_upload_size = nil)
|
||||||
if old_address != new_address
|
if old_address != new_address
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<% @title = "Edit Web" %>
|
<% @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>
|
<h2 style="margin-bottom: 3px">Name and address</h2>
|
||||||
<div class="help">
|
<div class="help">
|
||||||
The name of the web is included in the title on all pages.
|
The name of the web is included in the title on all pages.
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
<h1>Other administrative tasks</h1>
|
<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">
|
<p align="right">
|
||||||
<small>
|
<small>
|
||||||
Clean up by entering system password
|
Clean up by entering system password
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="navigation">
|
<div class="navigation">
|
||||||
<% if @page.name == "HomePage" %>
|
<% if @page.name == "HomePage" %>
|
||||||
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit Page</a>
|
<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 %>
|
<% else %>
|
||||||
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit</a>
|
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -68,7 +68,6 @@ class DispatchServlet
|
||||||
'file' => 'file',
|
'file' => 'file',
|
||||||
'import' => 'file',
|
'import' => 'file',
|
||||||
'pic' => 'file',
|
'pic' => 'file',
|
||||||
'update_web' => 'admin'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.map_to_controller(action)
|
def self.map_to_controller(action)
|
||||||
|
|
|
@ -112,10 +112,10 @@ class AdminControllerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_update_web
|
def test_edit_web
|
||||||
@wiki.system[:password] = 'pswd'
|
@wiki.system[:password] = 'pswd'
|
||||||
|
|
||||||
process('update_web', 'system_password' => 'pswd',
|
process('edit_web', 'system_password' => 'pswd',
|
||||||
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
||||||
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
||||||
'safe_mode' => 'on', 'password' => 'new_password', 'published' => 'on',
|
'safe_mode' => 'on', 'password' => 'new_password', 'published' => 'on',
|
||||||
|
@ -136,10 +136,10 @@ class AdminControllerTest < Test::Unit::TestCase
|
||||||
assert_equal 300, @web.max_upload_size
|
assert_equal 300, @web.max_upload_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_web_opposite_values
|
def test_edit_web_opposite_values
|
||||||
@wiki.system[:password] = 'pswd'
|
@wiki.system[:password] = 'pswd'
|
||||||
|
|
||||||
process('update_web', 'system_password' => 'pswd',
|
process('edit_web', 'system_password' => 'pswd',
|
||||||
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
|
||||||
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
|
||||||
'password' => 'new_password')
|
'password' => 'new_password')
|
||||||
|
|
Loading…
Reference in a new issue