Browse Source

pyi2phosts/urls.py: add generic view for browsing latest hosts

pull/1/head
Hidden Z 14 years ago
parent
commit
e346df0481
  1. 19
      pyi2phosts/urls.py

19
pyi2phosts/urls.py

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
import datetime
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.views.generic.list_detail import object_list
@ -30,6 +31,23 @@ browse_hosts = { @@ -30,6 +31,23 @@ browse_hosts = {
}
}
day_count = 30
hosts_count = 40
now_date = datetime.datetime.utcnow()
start_date = now_date - datetime.timedelta(days=day_count)
latest_hosts = {
'queryset': i2phost.objects.filter(activated=True,
date_added__range=(start_date, now_date)).order_by("-date_added")[:hosts_count],
'template_name': 'latest.html',
'template_object_name': 'host',
'paginate_by': 40,
'extra_context': {
'title': settings.SITE_NAME,
'day_count': day_count,
'hosts_count': hosts_count,
}
}
urlpatterns = patterns('',
url(r'^$', direct_to_template, {
'template': 'index.html',
@ -42,6 +60,7 @@ urlpatterns = patterns('', @@ -42,6 +60,7 @@ urlpatterns = patterns('',
}, name='index'),
url(r'^faq/$', object_list, extsources, name='faq'),
url(r'^browse/$', object_list, browse_hosts, name='browse'),
url(r'^latest/$', object_list, latest_hosts, name='latest'),
(r'^postkey/', include('pyi2phosts.postkey.urls')),
(r'^jump/', include('pyi2phosts.jump.urls')),
# Example:

Loading…
Cancel
Save