From 83531c5f775d461a1cceb3e9c73fa741d1c57ce6 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Tue, 8 Feb 2022 17:08:03 +0100 Subject: [PATCH] #86 Autocomplete enhancement * adds support for title lookup on EcoAccounts * adds support for title lookup on Interventions * adds support for email lookup on User --- konova/autocompletes.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/konova/autocompletes.py b/konova/autocompletes.py index 3c12b36d..3a79ab68 100644 --- a/konova/autocompletes.py +++ b/konova/autocompletes.py @@ -35,8 +35,9 @@ class EcoAccountAutocomplete(Select2QuerySetView): ) if self.q: qs = qs.filter( - identifier__icontains=self.q - ) + Q(identifier__icontains=self.q) | + Q(title__icontains=self.q) + ).distinct() return qs @@ -57,8 +58,9 @@ class InterventionAutocomplete(Select2QuerySetView): ) if self.q: qs = qs.filter( - identifier__icontains=self.q - ) + Q(identifier__icontains=self.q) | + Q(title__icontains=self.q) + ).distinct() return qs @@ -81,8 +83,9 @@ class ShareUserAutocomplete(Select2QuerySetView): if self.q: # Due to privacy concerns only a full username match will return the proper user entry qs = qs.filter( - username=self.q - ) + Q(username=self.q) | + Q(email=self.q) + ).distinct() return qs