Publish dates in the future shouldn't appear.
parent
74f060dfec
commit
94dfa02eb2
|
@ -5,13 +5,19 @@ from django.conf import settings
|
||||||
|
|
||||||
from snipts.models import Snipt
|
from snipts.models import Snipt
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
def blog_list(request, username_or_custom_slug=None):
|
def blog_list(request, username_or_custom_slug=None):
|
||||||
|
|
||||||
if username_or_custom_slug:
|
if username_or_custom_slug:
|
||||||
return blog_post(request, username_or_custom_slug)
|
return blog_post(request, username_or_custom_slug)
|
||||||
|
|
||||||
snipts = Snipt.objects.filter(user=request.blog_user, blog_post=True, public=True).order_by('-publish_date').exclude(title__iexact='Homepage')
|
snipts = Snipt.objects.filter(user=request.blog_user,
|
||||||
|
blog_post=True,
|
||||||
|
public=True,
|
||||||
|
publish_date__lte=datetime.datetime.now()
|
||||||
|
).order_by('-publish_date').exclude(title__iexact='Homepage')
|
||||||
|
|
||||||
sidebar = get_object_or_None(Snipt,
|
sidebar = get_object_or_None(Snipt,
|
||||||
user=request.blog_user,
|
user=request.blog_user,
|
||||||
|
@ -29,10 +35,12 @@ def blog_list(request, username_or_custom_slug=None):
|
||||||
context['snipts'] = context['snipts'][:20]
|
context['snipts'] = context['snipts'][:20]
|
||||||
return rss(request, context)
|
return rss(request, context)
|
||||||
|
|
||||||
if request.blog_user.profile.is_pro and settings.DEBUG:
|
#if request.blog_user.profile.is_pro and settings.DEBUG:
|
||||||
template = 'blogs/themes/pro-adams/list.html'
|
#template = 'blogs/themes/pro-adams/list.html'
|
||||||
else:
|
#else:
|
||||||
template = 'blogs/themes/default/list.html'
|
#template = 'blogs/themes/default/list.html'
|
||||||
|
|
||||||
|
template = 'blogs/themes/default/list.html'
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
template,
|
template,
|
||||||
|
@ -45,6 +53,7 @@ def blog_post(request, username_or_custom_slug):
|
||||||
snipt = get_object_or_404(Snipt, user=request.blog_user,
|
snipt = get_object_or_404(Snipt, user=request.blog_user,
|
||||||
blog_post=True,
|
blog_post=True,
|
||||||
public=True,
|
public=True,
|
||||||
|
publish_date__lte=datetime.datetime.now(),
|
||||||
slug=username_or_custom_slug,
|
slug=username_or_custom_slug,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,10 +70,12 @@ def blog_post(request, username_or_custom_slug):
|
||||||
'snipt': snipt,
|
'snipt': snipt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.blog_user.profile.is_pro and settings.DEBUG:
|
#if request.blog_user.profile.is_pro and settings.DEBUG:
|
||||||
template = 'blogs/themes/pro-adams/post.html'
|
#template = 'blogs/themes/pro-adams/post.html'
|
||||||
else:
|
#else:
|
||||||
template = 'blogs/themes/default/post.html'
|
#template = 'blogs/themes/default/post.html'
|
||||||
|
|
||||||
|
template = 'blogs/themes/default/post.html'
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
template,
|
template,
|
||||||
|
|
21
settings.py
21
settings.py
|
@ -216,13 +216,20 @@ ABSOLUTE_URL_OVERRIDES = {
|
||||||
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
|
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
|
||||||
|
|
||||||
# Search
|
# Search
|
||||||
HAYSTACK_CONNECTIONS = {
|
if not DEBUG:
|
||||||
'default': {
|
HAYSTACK_CONNECTIONS = {
|
||||||
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
|
'default': {
|
||||||
'URL': 'http://127.0.0.1:9200/',
|
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
|
||||||
'INDEX_NAME': 'haystack',
|
'URL': 'http://127.0.0.1:9200/',
|
||||||
},
|
'INDEX_NAME': 'haystack',
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
HAYSTACK_CONNECTIONS = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# Extensions
|
# Extensions
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
|
Loading…
Reference in New Issue