Mercurial > p > roundup > code
comparison roundup/admin.py @ 6250:95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
issue2550522 - Add 'filter' command to command-line interface.
Filter command was actually added in 2.0.0, but this
issue requested transitive searching. So that:
roundup-admin -i . filter issue assignedto.username=Admin
will work. This also fixes two bugs.
If assignedto.username had no matches, all issues would be returned.
admin.py had a find() call where the should have been a filter()
call. Was tripped when -S, -c or -s were used.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 05 Aug 2020 02:05:10 -0400 |
| parents | 74784dd531c8 |
| children | 51a1a9b0f567 |
comparison
equal
deleted
inserted
replaced
| 6249:3b62c35e824d | 6250:95183d73ac64 |
|---|---|
| 744 values = value.split(',') | 744 values = value.split(',') |
| 745 else: | 745 else: |
| 746 values = [ value ] | 746 values = [ value ] |
| 747 | 747 |
| 748 props[propname] = [] | 748 props[propname] = [] |
| 749 # start handling transitive props | |
| 750 # given filter issue assignedto.roles=Admin | |
| 751 # start at issue | |
| 752 curclass = cl | |
| 753 lastprop = propname # handle case 'issue assignedto=admin' | |
| 754 if '.' in propname: | |
| 755 # start splitting transitive prop into components | |
| 756 # we end when we have no more links | |
| 757 for pn in propname.split('.'): | |
| 758 try: | |
| 759 lastprop=pn # get current component | |
| 760 # get classname for this link | |
| 761 try: | |
| 762 curclassname = curclass.getprops()[pn].classname | |
| 763 except KeyError: | |
| 764 raise UsageError(_("Class %(curclassname)s has " | |
| 765 "no property %(pn)s in %(propname)s." % locals())) | |
| 766 # get class object | |
| 767 curclass = self.get_class(curclassname) | |
| 768 except AttributeError: | |
| 769 # curclass.getprops()[pn].classname raises this | |
| 770 # when we are at a non link/multilink property | |
| 771 pass | |
| 772 | |
| 749 for value in values: | 773 for value in values: |
| 750 val = hyperdb.rawToHyperdb(self.db, cl, None, | 774 val = hyperdb.rawToHyperdb(self.db, curclass, None, |
| 751 propname, value) | 775 lastprop, value) |
| 752 props[propname].append(val) | 776 props[propname].append(val) |
| 753 | 777 |
| 754 # now do the filter | 778 # now do the filter |
| 755 try: | 779 try: |
| 756 id = [] | 780 id = [] |
| 762 id = cl.filter(None, **props) | 786 id = cl.filter(None, **props) |
| 763 for i in id: | 787 for i in id: |
| 764 designator.append(classname + i) | 788 designator.append(classname + i) |
| 765 print(self.separator.join(designator)) | 789 print(self.separator.join(designator)) |
| 766 else: | 790 else: |
| 767 print(self.separator.join(cl.find(**props))) | 791 print(self.separator.join(cl.filter(None, **props))) |
| 768 else: | 792 else: |
| 769 if self.print_designator: | 793 if self.print_designator: |
| 770 id = cl.filter(None, **props) | 794 id = cl.filter(None, **props) |
| 771 for i in id: | 795 for i in id: |
| 772 designator.append(classname + i) | 796 designator.append(classname + i) |
