# -*- coding: utf-8 -*-
from django.http import Http404, HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.contrib.sites.models import SITE_CACHE
from pages import settings
from pages.models import Page, Content
from pages.utils import auto_render, get_language_from_request, get_page_from_slug


def details(request, slug=None, lang=None):
    """
    Example view that get the root pages for navigation,
    and the current page if there is any root page.
    All is rendered with the current page's template.
    """
    pages = Page.objects.navigation().order_by("tree_id")
    current_page = False

    if pages:
        if slug:
            current_page = get_page_from_slug(slug, request, lang)
        else:
            current_page = pages[0]

    if not current_page:
        raise Http404

    if not current_page.calculated_status in (Page.PUBLISHED, Page.HIDDEN):
        raise Http404
    
    if not lang:
        lang = get_language_from_request(request, current_page)
    
    if current_page.redirect_to:
        http_redirect = HttpResponsePermanentRedirect(current_page.redirect_to.get_absolute_url(lang))
        
    template_name = current_page.get_template()
    return template_name, locals()
details = auto_render(details)
@@ -640,26 +640,8 @@
 se%0A%0A
-    if pages:%0A    
     
@@ -649,20 +649,16 @@
 f slug:%0A
-    
         
@@ -720,22 +720,20 @@
     
-    else:%0A    
+elif pages:%0A
     
@@ -812,32 +812,106 @@
 404%0A%0A    if not 
+(request.user.is_authenticated() and request.user.is_staff) and %5C%0A        
 current_page.cal
@@ -938,30 +938,27 @@
 age.
-PUBLISHED, Page.HIDDEN
+DRAFT, Page.EXPIRED
 ):%0A 
@@ -1102,16 +1102,80 @@
 ect_to:%0A
+        # return this object if you want to active redirections%0A
         
@@ -1220,16 +1220,29 @@
 edirect(
+%0A            
 current_
@@ -1374,16 +1374,21 @@
 ocals()%0A
+    %0A
 details 

Fix issue 93 and apply some code cleanup on the example view