webui: merge 'move' form with 'rename' form
This commit is contained in:
parent
81c30b1cd1
commit
8417579147
|
@ -1267,7 +1267,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
|||
r'\s+<td align="right">%d</td>' % len(self.BAR_CONTENTS),
|
||||
])
|
||||
self.failUnless(re.search(get_bar, res), res)
|
||||
for label in ['unlink', 'rename', 'move']:
|
||||
for label in ['unlink', 'rename/move']:
|
||||
for line in res.split("\n"):
|
||||
# find the line that contains the relevant button for bar.txt
|
||||
if ("form action" in line and
|
||||
|
@ -1285,7 +1285,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
|||
self.failUnlessIn('method="post"', line)
|
||||
break
|
||||
else:
|
||||
self.fail("unable to find '%s bar.txt' line" % (label,), res)
|
||||
self.fail("unable to find '%s bar.txt' line" % (label,))
|
||||
|
||||
# the DIR reference just points to a URI
|
||||
sub_url = ("%s/uri/%s/" % (ROOT, urllib.quote(self._sub_uri)))
|
||||
|
@ -3480,15 +3480,6 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
|||
d.addCallback(_check)
|
||||
return d
|
||||
|
||||
def test_GET_move_form(self):
|
||||
d = self.GET(self.public_url + "/foo?t=move-form&name=bar.txt",
|
||||
followRedirect=True)
|
||||
def _check(res):
|
||||
self.failUnless('name="when_done" value="."' in res, res)
|
||||
self.failUnless(re.search(r'name="from_name" value="bar\.txt"', res))
|
||||
d.addCallback(_check)
|
||||
return d
|
||||
|
||||
def log(self, res, msg):
|
||||
#print "MSG: %s RES: %s" % (msg, res)
|
||||
log.msg(msg)
|
||||
|
|
|
@ -169,8 +169,6 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||
return DirectoryReadonlyURI(ctx, self.node)
|
||||
if t == 'rename-form':
|
||||
return RenameForm(self.node)
|
||||
if t == 'move-form':
|
||||
return MoveForm(self.node)
|
||||
|
||||
raise WebError("GET directory: bad t=%s" % t)
|
||||
|
||||
|
@ -718,7 +716,6 @@ class DirectoryAsHTML(rend.Page):
|
|||
if self.node.is_unknown() or self.node.is_readonly():
|
||||
unlink = "-"
|
||||
rename = "-"
|
||||
move = "-"
|
||||
else:
|
||||
# this creates a button which will cause our _POST_unlink method
|
||||
# to be invoked, which unlinks the file and then redirects the
|
||||
|
@ -734,19 +731,11 @@ class DirectoryAsHTML(rend.Page):
|
|||
T.input(type='hidden', name='t', value='rename-form'),
|
||||
T.input(type='hidden', name='name', value=name),
|
||||
T.input(type='hidden', name='when_done', value="."),
|
||||
T.input(type='submit', value='rename', name="rename"),
|
||||
]
|
||||
|
||||
move = T.form(action=here, method="get")[
|
||||
T.input(type='hidden', name='t', value='move-form'),
|
||||
T.input(type='hidden', name='name', value=name),
|
||||
T.input(type='hidden', name='when_done', value="."),
|
||||
T.input(type='submit', value='move', name="move"),
|
||||
T.input(type='submit', value='rename/move', name="rename"),
|
||||
]
|
||||
|
||||
ctx.fillSlots("unlink", unlink)
|
||||
ctx.fillSlots("rename", rename)
|
||||
ctx.fillSlots("move", move)
|
||||
|
||||
times = []
|
||||
linkcrtime = metadata.get('tahoe', {}).get("linkcrtime")
|
||||
|
@ -1008,33 +997,6 @@ class RenameForm(rend.Page):
|
|||
ctx.tag.attributes['value'] = name
|
||||
return ctx.tag
|
||||
|
||||
class MoveForm(rend.Page):
|
||||
addSlash = True
|
||||
docFactory = getxmlfile("move-form.xhtml")
|
||||
|
||||
def render_title(self, ctx, data):
|
||||
return ctx.tag["Directory SI=%s" % abbreviated_dirnode(self.original)]
|
||||
|
||||
def render_header(self, ctx, data):
|
||||
header = ["Move "
|
||||
"from directory SI=%s" % abbreviated_dirnode(self.original),
|
||||
]
|
||||
|
||||
if self.original.is_readonly():
|
||||
header.append(" (readonly!)")
|
||||
header.append(":")
|
||||
return ctx.tag[header]
|
||||
|
||||
def render_when_done(self, ctx, data):
|
||||
return T.input(type="hidden", name="when_done", value=".")
|
||||
|
||||
def render_get_name(self, ctx, data):
|
||||
req = IRequest(ctx)
|
||||
name = get_arg(req, "name", "")
|
||||
ctx.tag.attributes['value'] = name
|
||||
return ctx.tag
|
||||
|
||||
|
||||
class ManifestResults(rend.Page, ReloadMixin):
|
||||
docFactory = getxmlfile("manifest.xhtml")
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
<td><n:slot name="times"/></td>
|
||||
<td><n:slot name="unlink"/></td>
|
||||
<td><n:slot name="rename"/></td>
|
||||
<td><n:slot name="move"/></td>
|
||||
<td><n:slot name="info"/></td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
|
||||
<head>
|
||||
<title n:render="title"></title>
|
||||
<link href="/tahoe.css" rel="stylesheet" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2 n:render="header" />
|
||||
|
||||
<div class="freeform-form">
|
||||
<form action="." method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend class="freeform-form-label">Rename child</legend>
|
||||
<input type="hidden" name="t" value="move" />
|
||||
<input n:render="when_done" />
|
||||
|
||||
Move child:
|
||||
<input type="text" name="from_name" readonly="true"
|
||||
n:render="get_name" /><br />
|
||||
to
|
||||
<input type="text" name="to_dir" /><br />
|
||||
<input checked="checked" type="radio" id="tt-name"
|
||||
value="name" name="target_type" />
|
||||
<label for="tt-name"> Subdirectory</label>
|
||||
<input type="radio" id="tt-uri" value="uri" name="target_type"/>
|
||||
<label for="tt-uri"> URI</label> <br /><br />
|
||||
New name?
|
||||
<input type="text" name="to_name" />
|
||||
<input type="submit" value="move" /><br />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body></html>
|
|
@ -18,12 +18,33 @@
|
|||
<input n:render="when_done" />
|
||||
|
||||
Rename child:
|
||||
<input type="text" name="from_name" readonly="true" n:render="get_name" />
|
||||
to
|
||||
<input type="text" name="to_name" />
|
||||
<input type="text" name="from_name" readonly="true" n:render="get_name" /><br />
|
||||
to name:
|
||||
<input type="text" name="to_name" /><br />
|
||||
<input type="submit" value="rename" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<form action="." method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend class="freeform-form-label">Move Child to Different Directory</legend>
|
||||
<input type="hidden" name="t" value="move" />
|
||||
<input n:render="when_done" />
|
||||
|
||||
Move child: <input type="text" name="from_name" readonly="true"
|
||||
n:render="get_name" /><br />
|
||||
to name: <input type="text" name="to_name" n:render="get_name"/><br />
|
||||
in directory: <input type="text" name="to_dir" />
|
||||
<input checked="checked" type="radio" id="tt-name"
|
||||
value="name" name="target_type" />
|
||||
<label for="tt-name"> Subdirectory</label>
|
||||
<input type="radio" id="tt-uri" value="uri" name="target_type"/>
|
||||
<label for="tt-uri"> URI</label>
|
||||
<br />
|
||||
<input type="submit" value="move" /><br />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</body></html>
|
||||
|
|
Loading…
Reference in New Issue