We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

Commit 6152f748 authored by Gijs Hendriksen's avatar Gijs Hendriksen

Fixed keywords not being split when searching for members

parent 579d6546
......@@ -23,7 +23,7 @@ def index(request):
query_filter = '' if request.GET.get(
'filter') is None else request.GET.get('filter')
keywords = '' if request.GET.get('keywords') is None else request.GET.get(
'keywords')
'keywords').split()
page = request.GET.get('page')
page = 1 if page is None or not page.isdigit() else int(page)
......@@ -53,11 +53,12 @@ def index(request):
memberships_query = Q(until__gt=datetime.now().date()) | Q(until=None)
memberships_query &= Q(type='honorary')
if keywords is not None:
memberships_query &= (Q(user__member__nickname__icontains=keywords) |
Q(user__first_name__icontains=keywords) |
Q(user__last_name__icontains=keywords) |
Q(user__username__icontains=keywords))
if keywords:
for key in keywords:
memberships_query &= (Q(user__member__nickname__icontains=key) |
Q(user__first_name__icontains=key) |
Q(user__last_name__icontains=key) |
Q(user__username__icontains=key))
memberships = models.Membership.objects.filter(memberships_query)
members_query &= Q(user__in=memberships.values('user'))
......@@ -91,7 +92,7 @@ def index(request):
return render(request, 'members/index.html',
{'members': members, 'filter': query_filter,
'year_range': year_range, 'page_range': page_range,
'keywords': keywords})
'keywords': ' '.join(keywords)})
@login_required
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment