Django app to manage a private beta phase for a website.
- This app provides users with the change to sign up for a private beta - by providing their email address.
- The administrators of the website can manually invite people to join the beta from the Django admin panel.
- The signup view of the app is only accessible by providing the correct invitation code in the url.
- Install
django-hunger
usingpip
oreasy_install
. - Add
hunger
toINSTALLED_APPS
in settings.py. - Add
hunger.middleware.BetaMiddleware
toMIDDLEWARE_CLASSES
. - Create templates
beta/request_invite.html
,beta/confirmation.html
, andbeta/used.html
. Therequest_invite.html
template receives a Context instance with a Django form for the email signup form. Theconfirmation.html
andused.html
templates are flatpages for confirming signup and used invites. - By default Hunger redirects to "/beta/" if a users is not logged in. So your "request_invite" templates should be located here.
BETA_INVITE_CODE_LENGTH
- String length of the invitation_code (Default:
8
) BETA_ENABLE_BETA
- Enable hunger middleware (Default:
True
) BETA_NEVER_ALLOW_VIEWS
- Never allow access to these views (Default:
[]
) BETA_ALWAYS_ALLOW_VIEWS
- Always let unregistered user see these view (Default:
[]
) BETA_ALWAYS_ALLOW_MODULES
- Convenience settings - allow all views and a given module (Default:
[]
) BETA_ALLOW_FLATPAGES
- If using flatpages app (Default:
[]
) BETA_SIGNUP_VIEWS
- Which views are used for signing up (Default:
[]
) BETA_SIGNUP_CONFIRMATION_VIEW
- The view which comes directly after a user has signed up (Default:
''
) BETA_REDIRECT_URL
- If user is not logged in and trying to access a hidden view - where should
he/she be redirected (Default:
/beta/
) BETA_SIGNUP_URL
- What is the url for the signup page (Default:
/register/
) BETA_EMAIL_TEMPLATES_DIR
- Directory containing email templates (Default:
hunger
) BETA_EMAIL_MODULE
- Module where the email functions are (Default:
hunger.email
) BETA_EMAIL_CONFIRM_FUNCTION
- Function for sending out confirmation that user is on waiting list
(Default:
beta_confirm
) BETA_EMAIL_INVITE_FUNCTION
- Function for sending out the invitation code (Default:
beta_invite
)
If django_templated_email - https://github.com/bradwhittington/django-templated-email
is installed, you can use customized *.email
templates with an
example setting such as:
BETA_EMAIL_TEMPLATES_DIR = 'beta'
And create the following templates:
<project_dir>/templates/beta/beta_confirm.email <project_dir>/templates/beta/beta_invite.email
Modify SOCIAL_AUTH_PIPELINE
in settings to replace
social_auth.backends.pipeline.user.create_user
with
create_beta_user
(using default pipeline):
SOCIAL_AUTH_PIPELINE = ( 'social_auth.backends.pipeline.social.social_auth_user', 'social_auth.backends.pipeline.associate.associate_by_email', 'social_auth.backends.pipeline.user.get_username', 'hunger.contrib.social_auth_pipeline.create_beta_user', 'social_auth.backends.pipeline.social.associate_user', 'social_auth.backends.pipeline.social.load_extra_data', 'social_auth.backends.pipeline.user.update_user_details' )
BETA_ALWAYS_ALLOW_VIEWS
must at bare minimum include the relevant
social_auth views:
BETA_ALWAYS_ALLOW_VIEWS = ( 'social_auth.views.auth', 'social_auth.views.complete', )
Hunger is partially based on: - https://github.com/pragmaticbadger/django-privatebeta