Skip to content
📫 Email signup form for use on Democracy Club websites
Python HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dc_signup_form
test_project
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
MANIFEST.in
README.md
make_migrations.py
run_tests.py
setup.py
testing_requirements.txt

README.md

DC Signup Form

Build Status Coverage Status

Django app with Email signup form for use on Democracy Club websites

Installation

Add to project requirements:

git+git://github.com/DemocracyClub/dc_base_theme.git
git+git://github.com/DemocracyClub/dc_signup_form.git

Configuration

Using the remote backend (default):

INSTALLED_APPS = [
    ...
    'dc_signup_form',
]

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'dc_signup_form.context_processors.signup_form',
            ],
        },
    }
]

EMAIL_SIGNUP_API_KEY = 'f00b42'
EMAIL_SIGNUP_ENDPOINT = 'https://foo.bar/baz/'

Using the local backend:

INSTALLED_APPS = [
    ...
    'dc_signup_form',
    'dc_signup_form.signup_server',
]

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'dc_signup_form.context_processors.signup_form',
            ],
        },
    }
]

SENDGRID_API_KEY = 'f00b42'

Usage

Default routes:

url(r'^emails/', include('dc_signup_form.urls')),

Routes for local backend:

url(r'^emails/api_signup/', include('dc_signup_form.signup_server.urls')),

Custom routes:

from dc_signup_form.views import SignupFormView

email_urls = [
    url(r'^$',
        SignupFormView.as_view(
            template_name='email_form/mailing_list_form_view.html',
            form_class=MailingListSignupForm,
            get_vars=['postcode'],
            extras={
                'source': 'EveryElection',
            },
            thanks_message="My custom thanks message",
            backend='local_db'
        ),
        name='mailing_list_signup_view'),
]

# any custom urls we create must be declared in the 'dc_signup_form' namespace
urlpatterns += [
    url(r'^mailing_list/',
        include(email_urls, 'dc_signup_form', 'dc_signup_form')
    ),
]

Use as a standalone view

<a href="{% url 'dc_signup_form:mailing_list_signup_view' %}">Mailing List</a>

or display the form inline:

{% if not messages %}
  <div class="row">
    <div class="columns large-12">
      <div class="card">
        Sign up for our mailing list to receive election reminders
        {% include "email_form/election_reminders_form.html" %}
      </div>
    </div>
  </div>
{% endif %}
You can’t perform that action at this time.