changeset 5876:716d50585c8d

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.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 02 Sep 2019 16:11:17 +0200
parents 828bbf219e56
children 08b241c9fea4
files CHANGES.txt roundup/cgi/templating.py
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Wed Aug 28 17:25:59 2019 +0200
+++ b/CHANGES.txt	Mon Sep 02 16:11:17 2019 +0200
@@ -161,6 +161,11 @@
   dictionary in some cases where a single key should have been used.
   Thanks to Robert Klonner for discovering the problem, debugging the
   root cause and providing a first proposed fix.
+- Make searching with a multiselect work for Link/Multilink properties
+  that may contain numeric *key* values. For these a menu would render
+  options with IDs and later look up the IDs as *key* of the
+  Link/Multilink. Now numeric IDs take precedence -- like they already
+  do in the menu method of Link and Multilink.
 
 2018-07-13 1.6.0
 
--- a/roundup/cgi/templating.py	Wed Aug 28 17:25:59 2019 +0200
+++ b/roundup/cgi/templating.py	Mon Sep 02 16:11:17 2019 +0200
@@ -384,6 +384,10 @@
     cl = db.getclass(prop.classname)
     l = []
     for entry in ids:
+        # Do not look up numeric IDs
+        if num_re.match(entry):
+            l.append(entry)
+            continue
         if do_lookup:
             try:
                 item = cl.lookup(entry)
@@ -394,7 +398,7 @@
                 continue
         # if fail_ok, ignore lookup error
         # otherwise entry must be existing object id rather than key value
-        if fail_ok or num_re.match(entry):
+        if fail_ok:
             l.append(entry)
     return l
 

Roundup Issue Tracker: http://roundup-tracker.org/