From 94dfa02eb2683605c88c42da677d143a27f2a0a8 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Wed, 15 Aug 2012 11:04:15 -0400 Subject: [PATCH] Publish dates in the future shouldn't appear. --- blogs/views.py | 29 ++++++++++++++++++++--------- settings.py | 21 ++++++++++++++------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/blogs/views.py b/blogs/views.py index 62e3859..5e6a43f 100644 --- a/blogs/views.py +++ b/blogs/views.py @@ -5,13 +5,19 @@ from django.conf import settings from snipts.models import Snipt +import datetime + def blog_list(request, username_or_custom_slug=None): if 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, user=request.blog_user, @@ -29,10 +35,12 @@ def blog_list(request, username_or_custom_slug=None): context['snipts'] = context['snipts'][:20] return rss(request, context) - if request.blog_user.profile.is_pro and settings.DEBUG: - template = 'blogs/themes/pro-adams/list.html' - else: - template = 'blogs/themes/default/list.html' + #if request.blog_user.profile.is_pro and settings.DEBUG: + #template = 'blogs/themes/pro-adams/list.html' + #else: + #template = 'blogs/themes/default/list.html' + + template = 'blogs/themes/default/list.html' return render_to_response( template, @@ -45,6 +53,7 @@ def blog_post(request, username_or_custom_slug): snipt = get_object_or_404(Snipt, user=request.blog_user, blog_post=True, public=True, + publish_date__lte=datetime.datetime.now(), slug=username_or_custom_slug, ) @@ -61,10 +70,12 @@ def blog_post(request, username_or_custom_slug): 'snipt': snipt, } - if request.blog_user.profile.is_pro and settings.DEBUG: - template = 'blogs/themes/pro-adams/post.html' - else: - template = 'blogs/themes/default/post.html' + #if request.blog_user.profile.is_pro and settings.DEBUG: + #template = 'blogs/themes/pro-adams/post.html' + #else: + #template = 'blogs/themes/default/post.html' + + template = 'blogs/themes/default/post.html' return render_to_response( template, diff --git a/settings.py b/settings.py index 4bbe705..6bd2f36 100644 --- a/settings.py +++ b/settings.py @@ -216,13 +216,20 @@ ABSOLUTE_URL_OVERRIDES = { AUTH_PROFILE_MODULE = 'accounts.UserProfile' # Search -HAYSTACK_CONNECTIONS = { - 'default': { - 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', - 'URL': 'http://127.0.0.1:9200/', - 'INDEX_NAME': 'haystack', - }, -} +if not DEBUG: + HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', + 'URL': 'http://127.0.0.1:9200/', + 'INDEX_NAME': 'haystack', + }, + } +else: + HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', + }, + } # Extensions if DEBUG: