mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Quand match sur un field de user, prend en compte le filtre user_state
This commit is contained in:
parent
9a292d38d8
commit
5e3417cf17
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()
|
options, _ = GeneralOption.objects.get_or_create()
|
||||||
max_result = options.search_display_page
|
max_result = options.search_display_page
|
||||||
|
|
||||||
user_state_filter = Q()
|
|
||||||
for state in user_state:
|
|
||||||
user_state_filter |= Q(state=state)
|
|
||||||
|
|
||||||
results = {
|
results = {
|
||||||
'users_list': User.objects.none(),
|
'users_list': User.objects.none(),
|
||||||
'machines_list': Machine.objects.none(),
|
'machines_list': Machine.objects.none(),
|
||||||
|
@ -90,17 +86,19 @@ def get_results(query, request, filters={}):
|
||||||
|
|
||||||
# Users
|
# Users
|
||||||
if '0' in aff:
|
if '0' in aff:
|
||||||
filter_user_list = Q(
|
filter_user_list = (
|
||||||
surname__icontains=query
|
Q(
|
||||||
) | Q(
|
surname__icontains=query
|
||||||
adherent__name__icontains=query
|
) | Q(
|
||||||
) | Q(
|
adherent__name__icontains=query
|
||||||
pseudo__icontains=query
|
) | Q(
|
||||||
) | Q(
|
pseudo__icontains=query
|
||||||
club__room__name__icontains=query
|
) | Q(
|
||||||
) | Q(
|
club__room__name__icontains=query
|
||||||
adherent__room__name__icontains=query
|
) | Q(
|
||||||
) & user_state_filter
|
adherent__room__name__icontains=query
|
||||||
|
)
|
||||||
|
) & Q(state__in=user_state)
|
||||||
if not request.user.has_perms(('cableur',)):
|
if not request.user.has_perms(('cableur',)):
|
||||||
filter_user_list &= Q(id=request.user.id)
|
filter_user_list &= Q(id=request.user.id)
|
||||||
results['users_list'] = User.objects.filter(filter_user_list)
|
results['users_list'] = User.objects.filter(filter_user_list)
|
||||||
|
@ -115,8 +113,12 @@ def get_results(query, request, filters={}):
|
||||||
if '1' in aff:
|
if '1' in aff:
|
||||||
filter_machine_list = Q(
|
filter_machine_list = Q(
|
||||||
name__icontains=query
|
name__icontains=query
|
||||||
) | Q(
|
) | (
|
||||||
user__pseudo__icontains=query
|
Q(
|
||||||
|
user__pseudo__icontains=query
|
||||||
|
) & Q(
|
||||||
|
user__state__in=user_state
|
||||||
|
)
|
||||||
) | Q(
|
) | Q(
|
||||||
interface__domain__name__icontains=query
|
interface__domain__name__icontains=query
|
||||||
) | Q(
|
) | Q(
|
||||||
|
@ -140,6 +142,8 @@ def get_results(query, request, filters={}):
|
||||||
if '2' in aff:
|
if '2' in aff:
|
||||||
filter_facture_list = Q(
|
filter_facture_list = Q(
|
||||||
user__pseudo__icontains=query
|
user__pseudo__icontains=query
|
||||||
|
) & Q(
|
||||||
|
user__state__in=user_state
|
||||||
)
|
)
|
||||||
if start is not None:
|
if start is not None:
|
||||||
filter_facture_list &= Q(date__gte=start)
|
filter_facture_list &= Q(date__gte=start)
|
||||||
|
@ -155,8 +159,12 @@ def get_results(query, request, filters={}):
|
||||||
|
|
||||||
# Bans
|
# Bans
|
||||||
if '3' in aff:
|
if '3' in aff:
|
||||||
date_filter = Q(
|
date_filter = (
|
||||||
user__pseudo__icontains=query
|
Q(
|
||||||
|
user__pseudo__icontains=query
|
||||||
|
) & Q(
|
||||||
|
user__state__in=user_state
|
||||||
|
)
|
||||||
) | Q(
|
) | Q(
|
||||||
raison__icontains=query
|
raison__icontains=query
|
||||||
)
|
)
|
||||||
|
@ -186,8 +194,12 @@ def get_results(query, request, filters={}):
|
||||||
|
|
||||||
# Whitelists
|
# Whitelists
|
||||||
if '4' in aff:
|
if '4' in aff:
|
||||||
date_filter = Q(
|
date_filter = (
|
||||||
user__pseudo__icontains=query
|
Q(
|
||||||
|
user__pseudo__icontains=query
|
||||||
|
) & Q(
|
||||||
|
user__state__in=user_state
|
||||||
|
)
|
||||||
) | Q(
|
) | Q(
|
||||||
raison__icontains=query
|
raison__icontains=query
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue