mirror of
https://github.com/nanoy42/coope
synced 2024-11-05 01:16:28 +00:00
Merge branch 'search' into dev
This commit is contained in:
commit
dcabaaf4c0
2 changed files with 14 additions and 9 deletions
|
@ -532,7 +532,7 @@ class ProductsAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = Product.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
qs = qs.filter(name__contains=self.q)
|
||||
return qs
|
||||
|
||||
class ActiveProductsAutocomplete(autocomplete.Select2QuerySetView):
|
||||
|
@ -542,7 +542,7 @@ class ActiveProductsAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = Product.objects.filter(is_active=True)
|
||||
if self.q:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
qs = qs.filter(name__contains=self.q)
|
||||
return qs
|
||||
|
||||
########## Kegs ##########
|
||||
|
@ -790,7 +790,7 @@ class KegActiveAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = Keg.objects.filter(is_active = True)
|
||||
if self.q:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
qs = qs.filter(name__contains=self.q)
|
||||
return qs
|
||||
|
||||
class KegPositiveAutocomplete(autocomplete.Select2QuerySetView):
|
||||
|
@ -800,7 +800,7 @@ class KegPositiveAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = Keg.objects.filter(stockHold__gt = 0)
|
||||
if self.q:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
qs = qs.filter(name__contains=self.q)
|
||||
return qs
|
||||
|
||||
########## Menus ##########
|
||||
|
@ -957,7 +957,7 @@ class MenusAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = Menu.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
qs = qs.filter(name__contains=self.q)
|
||||
return qs
|
||||
|
||||
########## Ranking ##########
|
||||
|
|
|
@ -1079,7 +1079,7 @@ class AllUsersAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = User.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(Q(username__istartswith=self.q) | Q(first_name__istartswith=self.q) | Q(last_name__istartswith=self.q))
|
||||
qs = qs.filter(Q(username__contains=self.q) | Q(first_name__contains=self.q) | Q(last_name__contains=self.q))
|
||||
return qs
|
||||
|
||||
class ActiveUsersAutocomplete(autocomplete.Select2QuerySetView):
|
||||
|
@ -1089,7 +1089,7 @@ class ActiveUsersAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = User.objects.filter(is_active=True)
|
||||
if self.q:
|
||||
qs = qs.filter(Q(username__istartswith=self.q) | Q(first_name__istartswith=self.q) | Q(last_name__istartswith=self.q))
|
||||
qs = qs.filter(Q(username__contains=self.q) | Q(first_name__contains=self.q) | Q(last_name__contains=self.q))
|
||||
return qs
|
||||
|
||||
class AdherentAutocomplete(autocomplete.Select2QuerySetView):
|
||||
|
@ -1098,8 +1098,13 @@ class AdherentAutocomplete(autocomplete.Select2QuerySetView):
|
|||
"""
|
||||
def get_queryset(self):
|
||||
qs = User.objects.all()
|
||||
pks = [x.pk for x in qs if x.is_adherent]
|
||||
qs = User.objects.filter(pk__in=pks)
|
||||
if self.q:
|
||||
qs = qs.filter(Q(username__contains=self.q) | Q(first_name__contains=self.q) | Q(last_name__contains=self.q))
|
||||
return qs
|
||||
|
||||
|
||||
class NonSuperUserAutocomplete(autocomplete.Select2QuerySetView):
|
||||
"""
|
||||
Autocomplete for non-superuser users
|
||||
|
@ -1107,7 +1112,7 @@ class NonSuperUserAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = User.objects.filter(is_superuser=False)
|
||||
if self.q:
|
||||
qs = qs.filter(Q(username__istartswith=self.q) | Q(first_name__istartswith=self.q) | Q(last_name__istartswith=self.q))
|
||||
qs = qs.filter(Q(username__contains=self.q) | Q(first_name__contains=self.q) | Q(last_name__contains=self.q))
|
||||
return qs
|
||||
|
||||
class NonAdminUserAutocomplete(autocomplete.Select2QuerySetView):
|
||||
|
@ -1117,5 +1122,5 @@ class NonAdminUserAutocomplete(autocomplete.Select2QuerySetView):
|
|||
def get_queryset(self):
|
||||
qs = User.objects.filter(is_staff=False)
|
||||
if self.q:
|
||||
qs = qs.filter(Q(username__istartswith=self.q) | Q(first_name__istartswith=self.q) | Q(last_name__istartswith=self.q))
|
||||
qs = qs.filter(Q(username__contains=self.q) | Q(first_name__contains=self.q) | Q(last_name__contains=self.q))
|
||||
return qs
|
Loading…
Reference in a new issue