parent
47aedc706b
commit
c3f6d6920e
@ -65,7 +65,7 @@ from django.utils import timezone
|
||||
from django.utils.html import escape
|
||||
from datetime import date, timedelta
|
||||
from django.utils.timezone import datetime
|
||||
from django.db.models import Q, Subquery, OuterRef, Count, F
|
||||
from django.db.models import Q, Subquery, OuterRef, Count, F, Func
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -926,8 +926,12 @@ def event_search(request, full=False):
|
||||
)
|
||||
if 'q' in request.GET:
|
||||
categories = Category.objects.filter(name__icontains=request.GET['q'])
|
||||
tags = list(set([item for row in Event.objects.extra(where=['%s ILIKE ANY (tags)'], params=[request.GET['q']]).values_list('tags', flat=True).distinct() for item in row]))
|
||||
tags.sort(key=lambda x: remove_accents(x).lower())
|
||||
s_q = remove_accents(request.GET['q'].lower())
|
||||
tags = Event.objects.extra(where=['%s ILIKE ANY (tags)'], params=[request.GET['q']]).annotate(arr_tags=Func(F('tags'), function='unnest')).values_list('arr_tags', flat=True).distinct()
|
||||
tags = [(t, remove_accents(t).lower()) for t in tags]
|
||||
tags = [t for t in tags if s_q == t[1]]
|
||||
tags.sort(key=lambda x: x[1])
|
||||
tags = [t[0] for t in tags]
|
||||
places = Place.objects.filter(Q(name__icontains=request.GET['q']))
|
||||
|
||||
paginator = PaginatorFilter(filter, 10, request)
|
||||
|
Loading…
Reference in New Issue
Block a user