Skip to content

Commit 2ada1ed

Browse files
committed
Fix Link/Multilink searching
.. for the case that a key property may contain numeric values. This already was correct for menu (in an item template) but was doing the wrong thing for index templates.
1 parent 6999d14 commit 2ada1ed

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ Fixed:
161161
dictionary in some cases where a single key should have been used.
162162
Thanks to Robert Klonner for discovering the problem, debugging the
163163
root cause and providing a first proposed fix.
164+
- Make searching with a multiselect work for Link/Multilink properties
165+
that may contain numeric *key* values. For these a menu would render
166+
options with IDs and later look up the IDs as *key* of the
167+
Link/Multilink. Now numeric IDs take precedence -- like they already
168+
do in the menu method of Link and Multilink.
164169

165170
2018-07-13 1.6.0
166171

roundup/cgi/templating.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ def lookupIds(db, prop, ids, fail_ok=0, num_re=num_re, do_lookup=True):
384384
cl = db.getclass(prop.classname)
385385
l = []
386386
for entry in ids:
387+
# Do not look up numeric IDs
388+
if num_re.match(entry):
389+
l.append(entry)
390+
continue
387391
if do_lookup:
388392
try:
389393
item = cl.lookup(entry)
@@ -394,7 +398,7 @@ def lookupIds(db, prop, ids, fail_ok=0, num_re=num_re, do_lookup=True):
394398
continue
395399
# if fail_ok, ignore lookup error
396400
# otherwise entry must be existing object id rather than key value
397-
if fail_ok or num_re.match(entry):
401+
if fail_ok:
398402
l.append(entry)
399403
return l
400404

0 commit comments

Comments
 (0)