comparison 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
comparison
equal deleted inserted replaced
5841:f2804ec3bd06 5842:9c6617857032
679 if not self.db.security.hasSearchPermission( 679 if not self.db.security.hasSearchPermission(
680 uid, class_name, key 680 uid, class_name, key
681 ): 681 ):
682 continue 682 continue
683 if isinstance (prop, (hyperdb.Link, hyperdb.Multilink)): 683 if isinstance (prop, (hyperdb.Link, hyperdb.Multilink)):
684 vals = [] 684 if key in filter_props:
685 vals = filter_props[key]
686 else:
687 vals = []
685 linkcls = self.db.getclass (prop.classname) 688 linkcls = self.db.getclass (prop.classname)
686 for p in value.split(","): 689 for p in value.split(","):
687 if prop.try_id_parsing and p.isdigit(): 690 if prop.try_id_parsing and p.isdigit():
688 vals.append(p) 691 vals.append(p)
689 else: 692 else:
690 vals.append(linkcls.lookup(p)) 693 vals.append(linkcls.lookup(p))
691 filter_props[key] = vals 694 filter_props[key] = vals
692 else: 695 else:
693 filter_props[key] = value 696 if key in filter_props:
697 if isinstance(filter_props[key], list):
698 filter_props[key].append(value)
699 else:
700 filter_props[key]=[filter_props[key],value]
701 else:
702 filter_props[key] = value
694 if not filter_props: 703 if not filter_props:
695 obj_list = class_obj.list() 704 obj_list = class_obj.list()
696 else: 705 else:
697 obj_list = class_obj.filter(None, filter_props) 706 obj_list = class_obj.filter(None, filter_props)
698 707

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