mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-03-09 20:01:18 +00:00
pyi2phosts/urls.py: add generic view for browsing latest hosts
This commit is contained in:
parent
2b9346a404
commit
e346df0481
@ -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 = {
|
||||
}
|
||||
}
|
||||
|
||||
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('',
|
||||
}, 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…
x
Reference in New Issue
Block a user