diff roundup/rest.py @ 5842:9c6617857032

Support use of duplicate rest filters keys. So URL's like: issues?title=foo&title=bar will find titles with the words foo and bar but not just foo and not just bar. Url like: issues?status=open,resolved&status=closed will find any issue with open, closed or resolved status. Original code would only use the last title or status filter erasing the earlier one.
author John Rouillard <rouilj@ieee.org>
date Wed, 10 Jul 2019 20:49:41 -0400
parents 352e78c3b4ab
children 167ef847fcdf
line wrap: on
line diff
--- a/roundup/rest.py	Wed Jul 10 19:30:09 2019 -0400
+++ b/roundup/rest.py	Wed Jul 10 20:49:41 2019 -0400
@@ -681,7 +681,10 @@
                 ):
                     continue
                 if isinstance (prop, (hyperdb.Link, hyperdb.Multilink)):
-                    vals = []
+                    if key in filter_props:
+                        vals = filter_props[key]
+                    else:
+                        vals = []
                     linkcls = self.db.getclass (prop.classname)
                     for p in value.split(","):
                         if prop.try_id_parsing and p.isdigit():
@@ -690,7 +693,13 @@
                             vals.append(linkcls.lookup(p))
                     filter_props[key] = vals
                 else:
-                    filter_props[key] = value
+                    if key in filter_props:
+                        if isinstance(filter_props[key], list):
+                            filter_props[key].append(value)
+                        else:
+                            filter_props[key]=[filter_props[key],value]
+                    else:
+                        filter_props[key] = value
         if not filter_props:
             obj_list = class_obj.list()
         else:

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