Compare commits
1 commit
master
...
bclement/a
Author | SHA1 | Date | |
---|---|---|---|
|
f59e868793 |
3 changed files with 12 additions and 2 deletions
|
@ -905,6 +905,9 @@ class ParticipantAutocomplete(Select2QuerySetView):
|
||||||
model = Participant
|
model = Participant
|
||||||
search_fields = ("user__username", "user__first_name", "user__last_name")
|
search_fields = ("user__username", "user__first_name", "user__last_name")
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().select_related("user", "tirage")
|
||||||
|
|
||||||
|
|
||||||
participant_autocomplete = buro_required(ParticipantAutocomplete.as_view())
|
participant_autocomplete = buro_required(ParticipantAutocomplete.as_view())
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ class KfetAccountSearch(autocomplete.ModelSearch):
|
||||||
]
|
]
|
||||||
verbose_name = _("Comptes existants")
|
verbose_name = _("Comptes existants")
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().select_related("profile__account_kfet")
|
||||||
|
|
||||||
def get_queryset_filter(self, *args, **kwargs):
|
def get_queryset_filter(self, *args, **kwargs):
|
||||||
qset_filter = super().get_queryset_filter(*args, **kwargs)
|
qset_filter = super().get_queryset_filter(*args, **kwargs)
|
||||||
qset_filter &= Q(profile__account_kfet__isnull=False)
|
qset_filter &= Q(profile__account_kfet__isnull=False)
|
||||||
|
|
|
@ -98,7 +98,11 @@ class ModelSearch(SearchUnit):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if self.verbose_name is None:
|
if self.verbose_name is None:
|
||||||
self.verbose_name = "{} search".format(self.model._meta.verbose_name)
|
model = self.get_queryset().model
|
||||||
|
self.verbose_name = "{} search".format(model._meta.verbose_name)
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.model.objects.all()
|
||||||
|
|
||||||
def get_queryset_filter(self, keywords):
|
def get_queryset_filter(self, keywords):
|
||||||
filter_q = Q()
|
filter_q = Q()
|
||||||
|
@ -122,7 +126,7 @@ class ModelSearch(SearchUnit):
|
||||||
of the search fields.
|
of the search fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.model.objects.filter(self.get_queryset_filter(keywords))
|
return self.get_queryset().filter(self.get_queryset_filter(keywords))
|
||||||
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
Loading…
Reference in a new issue