{% extends "base.html" %}
{% block title %} {{ _('Newsletter list') }} - {{ SITE_LONG_NAME }}{% endblock %}
{% block content_title %} {{ _('Newsletter list') }} {% endblock %}

{% block body %}
    <h3> {{ _('Subscribe to get the latest emails about upcoming contests and events.')}} </h3>
    <br/>
    <div style="width: 50%; margin: auto;">
    {% if request.user.is_authenticated %}
        <form method="POST" action="" class="form-area" style="width:100%;">
            {% csrf_token %}
            {{ formset.management_form }}
            <table class="table">
                <tr>
                    <th>{{ _('Newsletter') }}</th>
                    <th>{{ _('Subscribe') }}</th>
                </tr>
                {% for form in formset.forms %}
                    <tr>
                        <td>{{ form.id }}
                            <a href="{{ url('newsletter_archive', form.instance.newsletter.slug) }}">
                                {{ form.instance.newsletter.title }}</a>
                        </td>
                        <td>{{ form.subscribed }}</d>
                    </tr>
                {% endfor %}
            </table>
            <hr>
            <p>
                <input id="id_submit" name="submit" value="{{_('Update subscriptions')}}" type="submit" style="float: right">
            </p>
        </form>
    {% else %}
        <table class="form-area">
            <tr>
                <th>Newsletter</th>
            </tr>
            {% for newsletter in object_list %}
                <tr>
                    <td><a href="{{ url('newsletter_detail', newsletter.slug) }}">{{ newsletter.title }}</a></td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}
    </div>
{% endblock %}