A private beta app for Django 1.10+ and Python 3.5+.
He who answers the five questions--three questions--may cross in safety.
Any "traveler" who "answers the questions" may pass BridgekeeperMiddleware
and "cross in safety" to the beta views.
Questions are pluggable via BRIDGEKEEPER_QUESTIONS setting.
Unlike other private beta apps, immediate user sign up is not required. With
default BRIDGEKEEPER_QUESTIONS an invited AnonymousUser may browse the
beta views before--or without ever--signing up as long as their Invite is
valid.
During soft release of django-bridgekeeper, install directly from git repo:
$ pip install git+https://github.com/brettstil/django-bridgekeeper.git#egg=django-bridgekeeperAdd to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'bridgekeeper.apps.BridgekeeperConfig',
]Add BridgekeeperMiddleware to MIDDLEWARE settings after Django's authentication middleware:
MIDDDLEWARE = [
# ...
'django.contrib.auth.middleware.AuthenticationMiddleware',
'bridgekeeper.middleware.BridgekeeperMiddleware',
]For default valid_invite question, add bridgekeeper urls to root urls:
urlpatterns = [
# ...
url(r'^bridgekeeper/', include(
'bridgekeeper.urls', namespace='bridgekeeper')),
]Configure settings, especially redirect urls and allowed modules and views.
Just like the Monty Python sketch, BridgekeeperMiddleware asks a list of
questions to determine whether the traveler may pass.
Questions are defined in BRIDGEKEEPER_QUESTIONS setting.
Each question has three possible results:
return Truefor explicit yes, traveler may pass.BridgekeeperMiddleware.process_viewreturns immedateNoneand skips remaining questions inBRIDGEKEEPER_QUESTIONS.For example, in default question
enableexplicit yes is returned ifBRIDGEKEEPER_ENABLEsetting isFalse.return Falsefor explicit no, traveler may not pass and traveler cast into the gorge.BridgekeeperMiddleware.process_viewreturns immediateHttpResponseRedirecttoBRIDGEKEEPER_URL_GORGEand skips remaining questions inBRIDGEKEEPER_QUESTIONS.For example, in default question
valid_inviteexplicit no is returned if an existing invite code is expired. Remember, order ofBRIDGEKEEPER_QUESTIONSis important!return None, or justreturn, for no opinion.BridgekeeperMiddlewarecontinues to the next question, if any, inBRIDGEKEEPER_QUESTIONS.If all questions return
None, thenBridgekeeperMiddleware.process_viewalso simply returnsNoneand traveler may pass.
Available settings are:
BRIDGEKEEPER_INVITE_EXPIRED_SECONDSDefault:
NoneWith default
Nonesetting, created invite does not expire at predeterminedexpireddatetime.With integer setting, created invite
expiredset totimezone.now()+ the setting number of seconds.Created invite with manually set
expiredignores the setting.BRIDGEKEEPER_URL_GORGEDefault:
'/'Redirect url after a middleware question explicitly casts traveler into gorge.
BRIDGEKEEPER_URL_INVITED_OKDefault:
'/'Redirect url after traveler successfully visits
'invited'url and has invite code cookie set.BRIDGEKEEPER_URL_INVITED_INVALIDDefault:
'/'Redirect url after traveler visits
'invited'url with invalid or expired invite code.BRIDGEKEEPER_COOKIE_NAME- Default:
'bridgekeeper_invite_code' BRIDGEKEEPER_QUESTIONSDefault:
['bridgekeeper.middleware.authenticated', 'bridgekeeper.middleware.enable', 'bridgekeeper.middleware.allowed_module', 'bridgekeeper.middleware.allowed_view', 'bridgekeeper.middleware.valid_invite']Order of questions is important!
BRIDGEKEEPER_ENABLEDefault:
TrueSetting for
'bridgekeeper.middleware.enable'question.Completely disable bridgekeeper with a single setting.
BRIDGEKEEPER_ALLOWED_MODULESDefault:
[]Setting for
'bridgekeeper.middleware.allowed_module'question.Always allow views from these modules, for example
'welcome.views'.These modules are always allowed:
['django.contrib.admin.sites', 'django.contrib.auth.views', 'django.contrib.staticfiles.views', 'django.views.static'].BRIDGEKEEPER_ALLOWED_VIEWSDefault:
[]Setting for
'bridgekeeper.middleware.allowed_view'question.Always allow these views, for example
'landing.views.hello'.
Inspired by unmaintained https://github.com/pragmaticbadger/django-privatebeta and https://github.com/joshuakarjala/django-hunger