mirror of https://github.com/r4sas/py-i2phosts
Hidden Z
13 years ago
6 changed files with 77 additions and 59 deletions
@ -1,8 +1,9 @@
@@ -1,8 +1,9 @@
|
||||
from django.conf.urls.defaults import * |
||||
from pyi2phosts.lib.rss import LatestHostsFeed |
||||
from pyi2phosts.latest.views import LatestHostsListsView |
||||
|
||||
urlpatterns = patterns('pyi2phosts.latest.views', |
||||
url(r'^$', 'latest', name='latest'), |
||||
urlpatterns = patterns('', |
||||
url(r'^$', LatestHostsListsView.as_view(), name='latest'), |
||||
url(r'^rss/$', LatestHostsFeed(), name='latest-rss'), |
||||
|
||||
) |
||||
|
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
||||
from django.conf.urls.defaults import * |
||||
from pyi2phosts.search.views import SearchedHostsListsView |
||||
|
||||
urlpatterns = patterns('pyi2phosts.search.views', |
||||
(r'^$', 'search'), |
||||
urlpatterns = patterns('', |
||||
(r'^$', SearchedHostsListsView.as_view()), |
||||
) |
||||
|
@ -1,21 +1,18 @@
@@ -1,21 +1,18 @@
|
||||
from django.db.models import Q |
||||
from django.views.generic import list_detail |
||||
|
||||
import settings |
||||
from pyi2phosts.postkey.models import i2phost |
||||
from pyi2phosts.lib.generic import HostsListsView |
||||
|
||||
|
||||
def search(request): |
||||
q = request.GET.get('q', '') |
||||
fil = Q(name__icontains=q) | Q(b64hash__contains=q) |
||||
qs = i2phost.objects.filter(fil) |
||||
return list_detail.object_list( |
||||
request = request, |
||||
queryset = qs, |
||||
template_name = 'search_results.html', |
||||
template_object_name = 'host', |
||||
paginate_by = 40, |
||||
extra_context = { |
||||
'title': settings.SITE_NAME, |
||||
} |
||||
) |
||||
class SearchedHostsListsView(HostsListsView): |
||||
""" Renders list of hosts matching search request """ |
||||
|
||||
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 |
||||
|
||||
template_name = 'search_results.html' |
||||
template_object_name = 'host_list' |
||||
paginate_by = 40 |
||||
|
Loading…
Reference in new issue