Skip to content

Commit

Permalink
Cleaned up the code flow a bit for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Allik committed Mar 9, 2011
1 parent 67af13f commit 54fe5e3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cms/utils/page_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ def get_page_from_request(request, use_path=None):
if hasattr(request, '_current_page_cache'):
return request._current_page_cache

# Get a basic queryset for Page objects, depending on if we use the
# MODERATOR or not.
page_queryset = get_page_queryset(request)
site = Site.objects.get_current()

# Check if this is called from an admin request
Expand All @@ -55,11 +52,15 @@ def get_page_from_request(request, use_path=None):
request._current_page_cache = page
return page

# Get a basic queryset for Page objects, depending on if we use the
# MODERATOR or not.
pages = get_page_queryset(request)

# TODO: Isn't there a permission check needed here?
if 'preview' in request.GET:
pages = page_queryset.filter(site=site)
else:
pages = page_queryset.published().filter(site=site)
if not 'preview' in request.GET:
pages = pages.published()

pages = pages.filter(site=site)

# If use_path is given, someone already did the path cleaning
if use_path:
Expand Down

0 comments on commit 54fe5e3

Please sign in to comment.