Skip to content

Commit c818093

Browse files
author
Richard Jones
committed
Fix form handling of editing existing hyperdb items from a new item page.
1 parent bd3194e commit c818093

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Fixed:
1616
- Journal export of anydbm didn't correctly export previously empty values
1717
- Fix handling of defaults for date fields
1818
- Fix <form> name in user editing to allow multilink popups to work
19+
- Fix form handling of editing existing hyperdb items from a new item page.
1920

2021

2122
2007-02-15 1.3.3

roundup/cgi/actions.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.65 2007-04-19 12:18:50 stefan Exp $
1+
#$Id: actions.py,v 1.66 2007-04-27 00:17:11 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random, csv, codecs
44

@@ -367,13 +367,16 @@ def _editnodes(self, all_props, all_links):
367367
deps = {}
368368
links = {}
369369
for cn, nodeid, propname, vlist in all_links:
370-
if not all_props.has_key((cn, nodeid)):
370+
if not (nodeid or all_props.has_key((cn, nodeid))):
371371
# link item to link to doesn't (and won't) exist
372372
continue
373-
for value in vlist:
374-
if not all_props.has_key(value):
373+
374+
for vcn, vid in vlist:
375+
if vid == '-1': vid = None
376+
if not (vid or all_props.has_key((vcn, vid))):
375377
# link item to link to doesn't (and won't) exist
376378
continue
379+
value = (vcn, vid)
377380
deps.setdefault((cn, nodeid), []).append(value)
378381
links.setdefault(value, []).append((cn, nodeid, propname))
379382

@@ -401,36 +404,34 @@ def _editnodes(self, all_props, all_links):
401404
m = []
402405
for needed in order:
403406
props = all_props[needed]
404-
if not props:
405-
# nothing to do
406-
continue
407-
cn, nodeid = needed
408-
409-
if nodeid is not None and int(nodeid) > 0:
410-
# make changes to the node
411-
props = self._changenode(cn, nodeid, props)
412-
413-
# and some nice feedback for the user
414-
if props:
415-
info = ', '.join(map(self._, props.keys()))
416-
m.append(
417-
self._('%(class)s %(id)s %(properties)s edited ok')
418-
% {'class':cn, 'id':nodeid, 'properties':info})
407+
if props:
408+
cn, nodeid = needed
409+
410+
if nodeid is not None and int(nodeid) > 0:
411+
# make changes to the node
412+
props = self._changenode(cn, nodeid, props)
413+
414+
# and some nice feedback for the user
415+
if props:
416+
info = ', '.join(map(self._, props.keys()))
417+
m.append(
418+
self._('%(class)s %(id)s %(properties)s edited ok')
419+
% {'class':cn, 'id':nodeid, 'properties':info})
420+
else:
421+
m.append(self._('%(class)s %(id)s - nothing changed')
422+
% {'class':cn, 'id':nodeid})
419423
else:
420-
m.append(self._('%(class)s %(id)s - nothing changed')
421-
% {'class':cn, 'id':nodeid})
422-
else:
423-
assert props
424+
assert props
424425

425-
# make a new node
426-
newid = self._createnode(cn, props)
427-
if nodeid is None:
428-
self.nodeid = newid
429-
nodeid = newid
426+
# make a new node
427+
newid = self._createnode(cn, props)
428+
if nodeid is None:
429+
self.nodeid = newid
430+
nodeid = newid
430431

431-
# and some nice feedback for the user
432-
m.append(self._('%(class)s %(id)s created')
433-
% {'class':cn, 'id':newid})
432+
# and some nice feedback for the user
433+
m.append(self._('%(class)s %(id)s created')
434+
% {'class':cn, 'id':newid})
434435

435436
# fill in new ids in links
436437
if links.has_key(needed):

0 commit comments

Comments
 (0)