merged edit_web and update_web into one action

This commit is contained in:
Alexey Verkhovsky 2005-02-05 13:04:55 +00:00
parent 9cfa77dca2
commit 09cfb5635c
6 changed files with 33 additions and 28 deletions

View file

@ -44,26 +44,32 @@ class AdminController < ApplicationController
end end
def edit_web def edit_web
# to template if @params['system_password']
end # form submitted
if wiki.authenticate(@params['system_password'])
def update_web wiki.edit_web(
if wiki.authenticate(@params['system_password']) @web.address, @params['address'], @params['name'],
wiki.update_web( @params['markup'].intern,
@web.address, @params['address'], @params['name'], @params['color'], @params['additional_style'],
@params['markup'].intern, @params['safe_mode'] ? true : false,
@params['color'], @params['additional_style'], @params['password'].empty? ? nil : @params['password'],
@params['safe_mode'] ? true : false, @params['published'] ? true : false,
@params['password'].empty? ? nil : @params['password'], @params['brackets_only'] ? true : false,
@params['published'] ? true : false, @params['count_pages'] ? true : false,
@params['brackets_only'] ? true : false, @params['allow_uploads'] ? true : false,
@params['count_pages'] ? true : false, @params['max_upload_size']
@params['allow_uploads'] ? true : false, )
@params['max_upload_size'] redirect_show('HomePage', @params['address'])
) else
redirect_show('HomePage', @params['address']) 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 else
redirect_show('HomePage') # no form submitted - go to template
end end
end end

View file

@ -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

View file

@ -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

View file

@ -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 %>

View file

@ -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)

View file

@ -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')