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 """ |
||||||
fil = Q(name__icontains=q) | Q(b64hash__contains=q) |
|
||||||
qs = i2phost.objects.filter(fil) |
def get_queryset(self): |
||||||
return list_detail.object_list( |
q = self.request.GET.get('q', '') |
||||||
request = request, |
fil = Q(name__icontains=q) | Q(b64hash__contains=q) |
||||||
queryset = qs, |
queryset = i2phost.objects.filter(fil) |
||||||
template_name = 'search_results.html', |
return queryset |
||||||
template_object_name = 'host', |
|
||||||
paginate_by = 40, |
template_name = 'search_results.html' |
||||||
extra_context = { |
template_object_name = 'host_list' |
||||||
'title': settings.SITE_NAME, |
paginate_by = 40 |
||||||
} |
|
||||||
) |
|
||||||
|
Loading…
Reference in new issue