mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
21 lines
No EOL
718 B
Python
21 lines
No EOL
718 B
Python
from django.db.models import Q, Case, When, Value, IntegerField
|
|
|
|
from archivebox.search import search_index
|
|
|
|
class SearchResultsAdminMixin(object):
|
|
def get_search_results(self, request, queryset, search_term):
|
|
''' Show exact match for title and slug at top of admin search results.
|
|
'''
|
|
qs, use_distinct = \
|
|
super(SearchResultsAdminMixin, self).get_search_results(
|
|
request, queryset, search_term)
|
|
|
|
search_term = search_term.strip()
|
|
if not search_term:
|
|
return qs, use_distinct
|
|
|
|
snapshot_ids = search_index(search_term)
|
|
qsearch = queryset.filter(id__in=snapshot_ids)
|
|
qs |= qsearch
|
|
|
|
return qs, use_distinct |