Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Allow superusers to preview future blog posts. #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions basic/blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def post_detail(request, slug, year, month, day, **kwargs):
unpublished post detail for previewing purposes.
"""
posts = None
allow_future = False
if request.user.is_superuser:
posts = Post.objects.all()
allow_future = True
else:
posts = Post.objects.published()
return date_based.object_detail(
Expand All @@ -80,6 +82,7 @@ def post_detail(request, slug, year, month, day, **kwargs):
date_field='publish',
slug=slug,
queryset=posts,
allow_future=allow_future,
**kwargs
)
post_detail.__doc__ = date_based.object_detail.__doc__
Expand Down