Commit 2b9aff10 authored by Tres Seaver's avatar Tres Seaver

Collector #1065: add multi-rename

parent 0c99ceab
......@@ -83,7 +83,7 @@
#
##############################################################################
__doc__="""Copy interface"""
__version__='$Revision: 1.48 $'[11:-2]
__version__='$Revision: 1.49 $'[11:-2]
import sys, string, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps
......@@ -102,7 +102,7 @@ class CopyContainer(ExtensionClass.Base):
__ac_permissions__=(
('View management screens',
('manage_cutObjects', 'manage_copyObjects', 'manage_pasteObjects',
'manage_renameForm', 'manage_renameObject',)),
'manage_renameForm', 'manage_renameObjects', 'manage_renameObjects',)),
)
......@@ -120,6 +120,9 @@ class CopyContainer(ExtensionClass.Base):
def manage_CopyContainerFirstItem(self, REQUEST):
return self._getOb(REQUEST['ids'][0])
def manage_CopyContainerAllItems(self, REQUEST):
return map(lambda i, s=self: s._getOb(i), tuple(REQUEST['ids']))
def manage_cutObjects(self, ids, REQUEST=None):
"""Put a reference to the objects named in ids in the clip board"""
if type(ids) is type(''):
......@@ -241,6 +244,17 @@ class CopyContainer(ExtensionClass.Base):
manage_renameForm=Globals.HTMLFile('renameForm', globals())
def manage_renameObjects(self, ids, new_ids, REQUEST=None):
"""Rename several sub-objects"""
if len(ids) != len(new_ids):
raise 'BadRequst','Please rename each listed object.'
for i in range(len(ids)):
if ids[i] != new_ids[i]:
self.manage_renameObject(ids[i], new_ids[i], REQUEST)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
return None
def manage_renameObject(self, id, new_id, REQUEST=None):
"""Rename a particular sub-object"""
try: self._checkId(new_id)
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML lang="en">
<HEAD>
<TITLE>Rename Item</TITLE>
<TITLE>Rename Items</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<dtml-if expr="_.hasattr(REQUEST, 'ids') and REQUEST['ids']">
<dtml-with expr="manage_CopyContainerFirstItem(REQUEST)">
<dtml-if cb_isMoveable>
<dtml-if expr="_.hasattr(REQUEST, 'ids')">
<H2>Rename Items</H2>
<H2>Rename <dtml-var meta_type></H2>
<dtml-var "HelpSys.HelpButton('Folder_Rename.dtml','OFSP')">
......@@ -14,45 +13,40 @@
<P>
<FORM ACTION="<dtml-var URL1>" METHOD="POST">
<TABLE CELLSPACING="0">
<dtml-in expr="manage_CopyContainerAllItems(REQUEST)">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>" ALT="" BORDER="0">
</TD>
<dtml-if cb_isMoveable>
<TD ALIGN="LEFT" VALIGN="TOP">
<dtml-var id>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>to:</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="new_id" SIZE="20" value="&dtml-id;">
<INPUT TYPE="HIDDEN" NAME="ids:list" VALUE="<dtml-var id html_quote>">
<INPUT TYPE="TEXT" NAME="new_ids" SIZE="20" value="&dtml-id;">
</TD>
<dtml-else>
<TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="3">
<dtml-var id> may not be renamed.
</TD>
</dtml-if>
</TR>
</dtml-in>
<TR>
<TD></TD>
<TD>
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<dtml-var id html_quote>">
<TD COLSPAN="3">
<INPUT TYPE="HIDDEN" NAME=":default_method" VALUE="manage_renameObject">
<INPUT TYPE="submit" NAME="manage_renameObject:method" VALUE=" Ok ">
<INPUT TYPE="submit" NAME="manage_renameObjects:method" VALUE=" Ok ">
<INPUT TYPE="submit" NAME="manage_main:method" VALUE="Cancel">
</TD>
</TR>
</TABLE>
</FORM>
<dtml-else>
<FORM ACTION="manage_main" METHOD="GET">
<CENTER>
<BR><BR>
The item <EM><dtml-var id></EM> does not support this operation.
<P>
<INPUT TYPE="submit" NAME="submit" VALUE=" Ok ">
</CENTER>
</FORM>
</dtml-if>
</dtml-with>
<dtml-else>
<FORM ACTION="manage_main" METHOD="GET">
<CENTER>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment