2010-11-12 19:53:31 +00:00
|
|
|
from django.db.models import Q
|
|
|
|
|
|
|
|
from pyi2phosts.postkey.models import i2phost
|
2015-11-15 19:36:41 +00:00
|
|
|
from pyi2phosts.lib.generic import LocalObjectList
|
2010-11-12 19:53:31 +00:00
|
|
|
|
|
|
|
|
2015-11-15 19:36:41 +00:00
|
|
|
class SearchedHostsListsView(LocalObjectList):
|
2015-10-26 18:55:35 +00:00
|
|
|
""" Renders list of hosts matching search request """
|
2011-12-23 18:56:47 +00:00
|
|
|
|
2015-10-26 18:55:35 +00:00
|
|
|
def get_queryset(self):
|
|
|
|
q = self.request.GET.get('q', '')
|
|
|
|
fil = Q(name__icontains=q) | Q(b64hash__contains=q)
|
|
|
|
queryset = i2phost.objects.filter(fil)
|
|
|
|
return queryset
|
2011-12-23 18:56:47 +00:00
|
|
|
|
2015-10-26 18:55:35 +00:00
|
|
|
template_name = 'search_results.html'
|
2015-11-15 19:36:41 +00:00
|
|
|
context_object_name = 'host_list'
|
2015-10-26 18:55:35 +00:00
|
|
|
paginate_by = 40
|