mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Tweak filtering for users and clubs in search to better handle user-defined filters
This commit is contained in:
parent
33001cc734
commit
51f65340d8
1 changed files with 9 additions and 4 deletions
|
@ -112,17 +112,22 @@ def search_single_word(word, filters, user, start, end, user_state, aff):
|
|||
|
||||
# Users
|
||||
if "0" in aff:
|
||||
filter_users = (
|
||||
filter_clubs = (
|
||||
Q(surname__icontains=word)
|
||||
| Q(pseudo__icontains=word)
|
||||
| Q(room__name__icontains=word)
|
||||
| Q(email__icontains=word)
|
||||
| Q(telephone__icontains=word)
|
||||
) & Q(state__in=user_state)
|
||||
)
|
||||
filter_users = (filter_clubs | Q(name__icontains=word))
|
||||
|
||||
if not User.can_view_all(user)[0]:
|
||||
filter_clubs &= Q(id=user.id)
|
||||
filter_users &= Q(id=user.id)
|
||||
filter_clubs = filter_users
|
||||
filter_users |= Q(name__icontains=word)
|
||||
|
||||
filter_clubs &= Q(state__in=user_state)
|
||||
filter_users &= Q(state__in=user_state)
|
||||
|
||||
filters["users"] |= filter_users
|
||||
filters["clubs"] |= filter_clubs
|
||||
|
||||
|
|
Loading…
Reference in a new issue