mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 15:14:31 -04:00
Initial implementation
This commit is contained in:
parent
7bc13204e6
commit
b1f70b2197
7 changed files with 73 additions and 4 deletions
21
archivebox/core/mixins.py
Normal file
21
archivebox/core/mixins.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue