Skip to content

A reusable application for collecting email addresses for later invitations and to restrict access to a site under private beta.

License

Notifications You must be signed in to change notification settings

haitaoli/django-privatebeta

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-privatebeta

This reusable Django applications provides two things useful to a site under private (closed) beta:

  • A form that allows users to enter their email address so that you can send them an invite or a site launch notification later.
  • A middleware that locks the site down for non-logged in users. If you control account creation this is a very effective way of limiting a site to beta testers only.

Email invite form

To use the invite form, you first need to add privatebeta to INSTALLED_APPS in your settings file:

INSTALLED_APPS = (
...
'privatebeta',
)

You will also need to add

urlpatterns = patterns('',
    ...
    (r'^invites/', include('privatebeta.urls')),
)

You will also need to create two templates. The first is privatebeta/invite.html:

{% extends 'base.html' %}

{% block content %}
<h3>Enter your email address and we'll send you an invite soon</h3>
<form action="{% url privatebeta_invite %}" method="post">
{{ form }}
{% csrf_token %}
<input type="submit" value="Submit" />
</form>
{% endblock %}

When an email address is successfully entered, the user will be redirected to privatebeta/sent.html:

{% extends 'base.html' %}

{% block content %}
<p>Thanks, we'll be in touch!</p>
{% endblock %}

The above templates assume a standard Django template structure with a base.html template and a content block.

The included views take two optional keyword arguments for flexibility.:

template_name
The name of the tempalte to render. Optional, overrides the default template.
extra_context
A dictionary to add to the context of the view. Keys will become variable names and values will be accessible via those variables. Optional.

Closed beta middleware

If you would also like to prevent non-logged-in users from viewing your site, you can make use of privatebeta.middleware.PrivateBetaMiddleware. This middleware redirects all views to a specified location if a user is not logged in.

To use the middleware, add it to MIDDLEWARE_CLASSSES in your settings file:

MIDDLEWARE_CLASSES = (
    ...
    'privatebeta.middleware.PrivateBetaMiddleware',
)

There are a few settings that influence behavior of the middleware:

PRIVATEBETA_NEVER_ALLOW_VIEWS
A list of full view names that should never be displayed. This list is checked before the others so that this middleware exhibits deny then allow behavior.
PRIVATEBETA_ALWAYS_ALLOW_VIEWS
A list of full view names that should always pass through.
PRIVATEBETA_ALWAYS_ALLOW_MODULES
A list of modules that should always pass through. All views in django.contrib.auth.views, django.views.static and privatebeta.views will pass through unless they are explicitly prohibited in PRIVATEBETA_NEVER_ALLOW_VIEWS
PRIVATEBETA_REDIRECT_URL
The URL to redirect to. Can be relative or absolute.

Similar projects

  • Pinax includes a private beta project that shows how to dynamically enable or disable account creation in your urlconf in concert with a setting. It also includes a signup code app that allows you to create beta codes with a limited number of uses.
  • django-invitation is a reusable application designed to allow existing beta users to invite new users to the site for a viral beta. It builds on top of django-registration and can require an invite before a user is allowed to create an account.
  • django-invite is a lighter weight reusable application designed to restrict logins via an invite system.

Upgrading from 0.3

This application uses South (0.6.2 or greater) to manage schema migrations. If you don't already have South installed, you will need to do so:

  • Add south to your INSTALLED_APPS.
  • Run manage.py syncdb to install South.

Once South is installed, you will have to "fake" the schema for the 0.3 release, then migrate to 0.4.0:

  • Run manage.py migrate --fake privatebeta 0001.
  • Run manage.py migrate --list.
  • Verify that 0001_initial has been applied to privatebeta and 002_add_invited_field has not.
  • Run manage.py migrate privatebeta

Compatibility

This application is known to work with Django 1.0.X, Django 1.1.X & Django 1.2.X.

About

A reusable application for collecting email addresses for later invitations and to restrict access to a site under private beta.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%