remove old search implementation
This commit is contained in:
parent
d816762ea2
commit
c34334c7fe
2 changed files with 0 additions and 33 deletions
|
@ -1,32 +0,0 @@
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from c3nav.access.apply import filter_arealocations_by_access, filter_queryset_by_access
|
|
||||||
from c3nav.mapdata.models import LocationGroup
|
|
||||||
|
|
||||||
|
|
||||||
def filter_words(queryset, words):
|
|
||||||
for word in words:
|
|
||||||
queryset = queryset.filter(Q(name__icontains=word) | Q(titles__icontains=word))
|
|
||||||
return queryset
|
|
||||||
|
|
||||||
|
|
||||||
def search_location(request, search):
|
|
||||||
results = []
|
|
||||||
location = get_location(request, search)
|
|
||||||
if location:
|
|
||||||
results.append(location)
|
|
||||||
|
|
||||||
words = search.split(' ')[:10]
|
|
||||||
|
|
||||||
queryset = LocationGroup.objects.filter(can_seach=True).order_by('name')
|
|
||||||
if isinstance(location, LocationGroup):
|
|
||||||
queryset.exclude(name='g:' + location.name)
|
|
||||||
results += list(filter_words(filter_queryset_by_access(request, queryset), words)[:10])
|
|
||||||
|
|
||||||
queryset = AreaLocation.objects.filter(can_seach=True).order_by('name')
|
|
||||||
if isinstance(location, AreaLocation):
|
|
||||||
queryset.exclude(name=location.name)
|
|
||||||
results += sorted(filter_words(filter_arealocations_by_access(request, queryset), words),
|
|
||||||
key=AreaLocation.get_sort_key, reverse=True)
|
|
||||||
|
|
||||||
return results
|
|
|
@ -11,7 +11,6 @@ from c3nav.access.apply import get_visible_areas
|
||||||
from c3nav.mapdata.inclusion import get_includables_avoidables, parse_include_avoid
|
from c3nav.mapdata.inclusion import get_includables_avoidables, parse_include_avoid
|
||||||
from c3nav.mapdata.lastupdate import get_last_mapdata_update
|
from c3nav.mapdata.lastupdate import get_last_mapdata_update
|
||||||
from c3nav.mapdata.models.section import Section
|
from c3nav.mapdata.models.section import Section
|
||||||
from c3nav.mapdata.search import search_location
|
|
||||||
from c3nav.mapdata.utils.cache import get_sections_cached
|
from c3nav.mapdata.utils.cache import get_sections_cached
|
||||||
from c3nav.mapdata.utils.misc import get_dimensions, get_render_path
|
from c3nav.mapdata.utils.misc import get_dimensions, get_render_path
|
||||||
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound, NotYetRoutable
|
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound, NotYetRoutable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue