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 @@ |
|||||||
from django.conf.urls.defaults import * |
from django.conf.urls.defaults import * |
||||||
from pyi2phosts.lib.rss import LatestHostsFeed |
from pyi2phosts.lib.rss import LatestHostsFeed |
||||||
|
from pyi2phosts.latest.views import LatestHostsListsView |
||||||
|
|
||||||
urlpatterns = patterns('pyi2phosts.latest.views', |
urlpatterns = patterns('', |
||||||
url(r'^$', 'latest', name='latest'), |
url(r'^$', LatestHostsListsView.as_view(), name='latest'), |
||||||
url(r'^rss/$', LatestHostsFeed(), name='latest-rss'), |
url(r'^rss/$', LatestHostsFeed(), name='latest-rss'), |
||||||
|
|
||||||
) |
) |
||||||
|
@ -1,5 +1,6 @@ |
|||||||
from django.conf.urls.defaults import * |
from django.conf.urls.defaults import * |
||||||
|
from pyi2phosts.search.views import SearchedHostsListsView |
||||||
|
|
||||||
urlpatterns = patterns('pyi2phosts.search.views', |
urlpatterns = patterns('', |
||||||
(r'^$', 'search'), |
(r'^$', SearchedHostsListsView.as_view()), |
||||||
) |
) |
||||||
|
@ -1,21 +1,18 @@ |
|||||||
from django.db.models import Q |
from django.db.models import Q |
||||||
from django.views.generic import list_detail |
|
||||||
|
|
||||||
import settings |
|
||||||
from pyi2phosts.postkey.models import i2phost |
from pyi2phosts.postkey.models import i2phost |
||||||
|
from pyi2phosts.lib.generic import HostsListsView |
||||||
|
|
||||||
|
|
||||||
def search(request): |
class SearchedHostsListsView(HostsListsView): |
||||||
q = request.GET.get('q', '') |
""" 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) |
fil = Q(name__icontains=q) | Q(b64hash__contains=q) |
||||||
qs = i2phost.objects.filter(fil) |
queryset = i2phost.objects.filter(fil) |
||||||
return list_detail.object_list( |
return queryset |
||||||
request = request, |
|
||||||
queryset = qs, |
template_name = 'search_results.html' |
||||||
template_name = 'search_results.html', |
template_object_name = 'host_list' |
||||||
template_object_name = 'host', |
paginate_by = 40 |
||||||
paginate_by = 40, |
|
||||||
extra_context = { |
|
||||||
'title': settings.SITE_NAME, |
|
||||||
} |
|
||||||
) |
|
||||||
|
Loading…
Reference in new issue