Last active
August 29, 2015 14:11
-
-
Save cansadadeserfeliz/04cb5a9e6996ecfe511e to your computer and use it in GitHub Desktop.
Serve Sphinx documentation with Django only for admin users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
from django.contrib.auth.decorators import user_passes_test | |
from django.conf.urls import patterns, include, url | |
from django.views.static import serve | |
from django.conf import settings | |
urlpatterns = patterns( | |
'', | |
# Docs | |
url( | |
r'^docs/(?P<path>.*)$', | |
user_passes_test(lambda u: u.is_staff)(serve), | |
{ | |
'document_root': os.path.join(settings.BASE_DIR, 'doc/build/html'), | |
} | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment