Giter Site home page Giter Site logo

tswicegood / django-privatebeta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pragmaticbadger/django-privatebeta

1.0 4.0 1.0 80 KB

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

License: BSD 3-Clause "New" or "Revised" License

django-privatebeta's Introduction

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 }}
<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.

django-privatebeta's People

Contributors

mcroydon avatar

Stargazers

Travis Swicegood avatar

Watchers

Travis Swicegood avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.