{% extends "user_profile/user.html" %}
{% import "macros.html" as macros %}
<!-- user_email_subscriptions.html -->
{% block profilesection %}
    {% trans %}subscriptions{% endtrans %}
{% endblock %}
{% block usercontent %}
    <h2>{% trans %}Email subscription settings{% endtrans %}</h2>
    <p class="message">
{% trans %}<span class='big strong'>Adjust frequency of email updates.</span> Receive updates on interesting content by email. If you do not wish to receive emails - select 'no email' on all items below.<br/>Updates are only sent when there is any new activity on selected items.{% endtrans %}</p>
    <div>
    {% if action_status %}
        <p class="action-status"><span>{{action_status}}</span></p>
    {% endif %}
    <form method="post" action="">{% csrf_token %}
        <table class='form-as-table ab-subscr-form'>
        {{email_feeds_form.as_table()}}
        </table>
        <table class='form-as-table ab-tag-filter-form'>
        {{tag_filter_selection_form}}
        </table>
        <div class="submit-row text-align-right">
            <input type="submit" class="submit" name="save" value="{% trans %}Update{% endtrans %}"/>&nbsp;
            <input type="submit" class="submit" name="stop_email" value="{% trans %}Stop Email{% endtrans %}"/>
        </div>
    </form>
    </div>

    {% if settings.MULTILINGUAL %}
    <h2>{% trans %}Subscribed languages{% endtrans %}</h2>
    <form
        method="post" 
        action="{% url user_select_languages view_user.id, view_user.username|slugify %}"
    >{% csrf_token %}
        <select multiple name="languages">
        {% for lang in settings.LANGUAGES_DICT %}
            <option 
                value="{{ lang }}"
                {% if lang in user_languages %}selected="selected"{% endif %}
            >{{ settings.LANGUAGES_DICT[lang] }}</option>
        {% endfor %}
        </select><br/>
        <input type="submit" class="select-language" value="{% trans %}Save languages{% endtrans %}" />
    </form>
    {% endif %}

    {%if settings.SUBSCRIBED_TAG_SELECTOR_ENABLED %}
        <h2>{% trans %}Subscribed Tags{% endtrans %}</h2>
            {{
                macros.tag_list_widget(
                    subscribed_tag_names,
                    deletable = True,
                    css_class = 'subscribed marked-tags special',
                )
            }}
            <br/>
            <div class="inputs">
                <input id="subscribedTagInput" autocomplete="off" type="text"/>
                <input id="subscribedTagAdd" type="submit" value="{% trans %}add{% endtrans%}"/>
            </div>
        </div>
    {%endif%}
{% endblock %}
{%block userjs%}
  <script type='text/javascript'>
    search = new FullTextSearch();
    askbot['controllers'] = askbot['controllers'] || {}
    askbot['controllers']['fullTextSearch'] = search;
    askbot['urls']['mark_subscribed_tag'] = '{% url mark_subscribed_tag %}';
    askbot['urls']['unmark_tag'] = '{% url unmark_tag %}';
  </script>
  <script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
{% endblock %}
<!-- end user_email_subscriptions.html -->
