mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 06:32:26 +00:00
Quand match sur un field de user, prend en compte le filtre user_state
This commit is contained in:
parent
e5fbbec283
commit
aa6071a727
1 changed files with 33 additions and 21 deletions
|
@ -73,10 +73,6 @@ def get_results(query, request, filters={}):
|
|||
options, _ = GeneralOption.objects.get_or_create()
|
||||
max_result = options.search_display_page
|
||||
|
||||
user_state_filter = Q()
|
||||
for state in user_state:
|
||||
user_state_filter |= Q(state=state)
|
||||
|
||||
results = {
|
||||
'users_list': User.objects.none(),
|
||||
'machines_list': Machine.objects.none(),
|
||||
|
@ -90,7 +86,8 @@ def get_results(query, request, filters={}):
|
|||
|
||||
# Users
|
||||
if '0' in aff:
|
||||
filter_user_list = Q(
|
||||
filter_user_list = (
|
||||
Q(
|
||||
surname__icontains=query
|
||||
) | Q(
|
||||
adherent__name__icontains=query
|
||||
|
@ -100,7 +97,8 @@ def get_results(query, request, filters={}):
|
|||
club__room__name__icontains=query
|
||||
) | Q(
|
||||
adherent__room__name__icontains=query
|
||||
) & user_state_filter
|
||||
)
|
||||
) & Q(state__in=user_state)
|
||||
if not request.user.has_perms(('cableur',)):
|
||||
filter_user_list &= Q(id=request.user.id)
|
||||
results['users_list'] = User.objects.filter(filter_user_list)
|
||||
|
@ -115,8 +113,12 @@ def get_results(query, request, filters={}):
|
|||
if '1' in aff:
|
||||
filter_machine_list = Q(
|
||||
name__icontains=query
|
||||
) | Q(
|
||||
) | (
|
||||
Q(
|
||||
user__pseudo__icontains=query
|
||||
) & Q(
|
||||
user__state__in=user_state
|
||||
)
|
||||
) | Q(
|
||||
interface__domain__name__icontains=query
|
||||
) | Q(
|
||||
|
@ -140,6 +142,8 @@ def get_results(query, request, filters={}):
|
|||
if '2' in aff:
|
||||
filter_facture_list = Q(
|
||||
user__pseudo__icontains=query
|
||||
) & Q(
|
||||
user__state__in=user_state
|
||||
)
|
||||
if start is not None:
|
||||
filter_facture_list &= Q(date__gte=start)
|
||||
|
@ -155,8 +159,12 @@ def get_results(query, request, filters={}):
|
|||
|
||||
# Bans
|
||||
if '3' in aff:
|
||||
date_filter = Q(
|
||||
date_filter = (
|
||||
Q(
|
||||
user__pseudo__icontains=query
|
||||
) & Q(
|
||||
user__state__in=user_state
|
||||
)
|
||||
) | Q(
|
||||
raison__icontains=query
|
||||
)
|
||||
|
@ -186,8 +194,12 @@ def get_results(query, request, filters={}):
|
|||
|
||||
# Whitelists
|
||||
if '4' in aff:
|
||||
date_filter = Q(
|
||||
date_filter = (
|
||||
Q(
|
||||
user__pseudo__icontains=query
|
||||
) & Q(
|
||||
user__state__in=user_state
|
||||
)
|
||||
) | Q(
|
||||
raison__icontains=query
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue