{% extends 'base.html' %}

{% load static %}

{% block title %}Email Subscriptions{% endblock %}

{% block emailer_head %}
    <link rel="stylesheet" type="text/css" href="{% static 'django_simple_bulk_emailer/css/django_simple_bulk_emailer.css' %}">
{% endblock %}

{% block content %}

    <div id="emailer_content">

        <h1>
            Email Subscriptions
        </h1>
        <p>
            To subscribe or manage your subscriptions, submit your email address.
            You will receive an email with a link to a page where you can select or modify your subscriptions.
        </p>

        {% if subscription_set %}
            <p>
                Available subscriptions include:
            </p>

            <ul>
                {% for subscription in subscription_set %}
                    <li>
                        {{ subscription }}
                    </li>
                {% endfor %}
            </ul>
        {% endif %}

        <br>

        <form method="post" autocomplete="off">

            {% csrf_token %}

            <p>
                Email address:
                <br>
                <input type="text" id="emailer_hp_input" name="email" value="{% if form.email.value %}{{ form.email.value }}{% endif %}">
                <input type="text" class="emailer_input" name="subscriber_email" value="{% if form.subscriber_email.value %}{{ form.subscriber_email.value }}{% endif %}">
                {% if form.subscriber_email.errors %}
                    <br>
                    <span class="emailer_error">
                        Please enter a valid email address
                    </span>
                {% endif %}
            </p>

            <br>

            {{ form.captcha }}
            <br>

            <p>
                <input type="submit" value="Submit">
            </p>

        </form>

    </div>

{% endblock %}
