Browse Source

Move {days,hosts}_count from urls to settings

pull/1/head
Hidden Z 14 years ago
parent
commit
48ce4ba473
  1. 2
      pyi2phosts/settings.py
  2. 12
      pyi2phosts/urls.py

2
pyi2phosts/settings.py

@ -111,6 +111,8 @@ MY_B64 = 'my_base64_hash'
# also may be put in local settings: # also may be put in local settings:
LOG_LEVEL = 'debug' LOG_LEVEL = 'debug'
LOG_FILE = '/var/log/py-i2phosts/web.log' LOG_FILE = '/var/log/py-i2phosts/web.log'
LATEST_DAY_COUNT = 30
LATEST_HOSTS_COUNT = 40
# include local settings # include local settings

12
pyi2phosts/urls.py

@ -31,21 +31,18 @@ browse_hosts = {
} }
} }
# FIXME: move to settings
day_count = 30
hosts_count = 40
now_date = datetime.datetime.utcnow() now_date = datetime.datetime.utcnow()
start_date = now_date - datetime.timedelta(days=day_count) start_date = now_date - datetime.timedelta(days=settings.LATEST_DAY_COUNT)
latest_hosts = { latest_hosts = {
'queryset': i2phost.objects.filter(activated=True, 'queryset': i2phost.objects.filter(activated=True,
date_added__range=(start_date, now_date)).order_by("-date_added")[:hosts_count], date_added__range=(start_date, now_date)).order_by("-date_added")[:settings.LATEST_HOSTS_COUNT],
'template_name': 'latest.html', 'template_name': 'latest.html',
'template_object_name': 'host', 'template_object_name': 'host',
'paginate_by': 40, 'paginate_by': 40,
'extra_context': { 'extra_context': {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
'day_count': day_count, 'day_count': settings.LATEST_DAY_COUNT,
'hosts_count': hosts_count, 'hosts_count': settings.LATEST_HOSTS_COUNT,
} }
} }
@ -62,6 +59,7 @@ urlpatterns = patterns('',
url(r'^faq/$', object_list, extsources, name='faq'), url(r'^faq/$', object_list, extsources, name='faq'),
url(r'^browse/$', object_list, browse_hosts, name='browse'), url(r'^browse/$', object_list, browse_hosts, name='browse'),
url(r'^latest/$', object_list, latest_hosts, name='latest'), url(r'^latest/$', object_list, latest_hosts, name='latest'),
(r'^search/$', include('pyi2phosts.search.urls')), (r'^search/$', include('pyi2phosts.search.urls')),
(r'^postkey/', include('pyi2phosts.postkey.urls')), (r'^postkey/', include('pyi2phosts.postkey.urls')),
(r'^jump/', include('pyi2phosts.jump.urls')), (r'^jump/', include('pyi2phosts.jump.urls')),

Loading…
Cancel
Save