From 04c04a5eabd166df51ee6c910a4d56dd5da53d72 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 11 Dec 2002 01:46:46 +0000 Subject: [PATCH] allow multiple :remove and :add elements per property being edited git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1402 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + doc/customizing.txt | 8 +++++++- roundup/cgi/client.py | 13 ++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e29f68d..9cb3c5b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -21,6 +21,7 @@ are given with the most recent entry first. - allow StringHTMLProperty in MultilinkHTMLProperty test to work - don't set explicit None Link properties in web create - fixed nasty sorting bug that was lowercasing properties +- allow multiple :remove and :add elements per property being edited 2002-11-07 0.5.2 diff --git a/doc/customizing.txt b/doc/customizing.txt index 068e907..21f9e69 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -2,7 +2,7 @@ Customising Roundup =================== -:Version: $Revision: 1.64 $ +:Version: $Revision: 1.65 $ .. This document borrows from the ZopeBook section on ZPT. The original is at: http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx @@ -731,6 +731,12 @@ triggered by using a ``:action`` CGI variable, where the value is one of: the :note if it's supplied. :required=property,property,... The named properties are required to be filled in the form. + :remove:=id(s) + The ids will be removed from the multilink property. You may have multiple + :remove: form elements for a single . + :add:=id(s) + The ids will be added to the multilink property. You may have multiple + :add: form elements for a single . **new** Add a new item to the database. You may use the same special form elements diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 0c8deac..e338d7a 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.61 2002-12-10 23:39:40 richard Exp $ +# $Id: client.py,v 1.62 2002-12-11 01:46:46 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -1173,6 +1173,7 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): props = {} keys = form.keys() properties = cl.getprops() + existing_cache = {} for key in keys: # see if we're performing a special multilink action mlaction = 'set' @@ -1289,10 +1290,12 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): value = l else: # we're modifying the list - get the current list of ids - try: - existing = cl.get(nodeid, propname) - except KeyError: - existing = [] + if props.has_key(propname): + existing = props[propname] + else: + existing = cl.get(nodeid, propname, []) + + # now either remove or add if mlaction == 'remove': # remove - handle situation where the id isn't in the list for entry in l: -- 2.30.2