{% macro list_form(form, isnew) %}

<form class="list-settings" method="POST">
  {{ form.csrf_token }}

  {{ form.id.label }}
  <fieldset role="group">
    {{ form.id }}

    {{ form.domain(disabled="disabled", value="@" + config.DOMAIN) }}
  </fieldset>

  {{ form.display.label }}
  {{ form.display }}

  <h3>{{ _('Mode Settings') }}</h3>

  <fieldset class="list-no-bullets" id="mode-select">
    {{ form.mode.label }}
    {{ form.mode }}
  </fieldset>

  <fieldset class="mode-broadcast">
    {{ form.from_addr.label }}
    {{ form.from_addr(placeholder=("John Doe <john.doe@example.com>")) }}
      <small>{{ (form.from_addr.description) }}</small>
  </fieldset>

  <h3>{{ _('Sender Restrictions') }}</h3>

  <fieldset class="mode-group">
    <label>
      {{ form.only_subscribers_send(role="switch") }}
      {{ form.only_subscribers_send.label.text }}
      <small>{{ form.only_subscribers_send.description }}</small>
    </label>
  </fieldset>

  <fieldset class="auth">
    {{ form.allowed_senders.label }}
    {{ form.allowed_senders(placeholder=("user@example.com,another@example.com")) }}
    <small>{{ (form.allowed_senders.description) }}</small>

    {{ form.sender_auth.label }}
    {{ form.sender_auth(placeholder=("password1,password2")) }}
    <small>{{ (form.sender_auth.description) }}</small>
  </fieldset>

  <h3>{{ _('Additional Settings') }}</h3>

  <fieldset>
    <label>
      {{ form.avoid_duplicates(role="switch") }}
      {{ form.avoid_duplicates.label.text }}
      <small>{{ form.avoid_duplicates.description }}</small>
    </label>
  </fieldset>

  <hr />

  <details>
    <summary>{{ _('IMAP Settings') }}</summary>
    {{ form.imap_host.label }}
    {{ form.imap_host(placeholder=config.IMAP_DEFAULT_HOST) }}

    {{ form.imap_port.label }}
    {{ form.imap_port(placeholder=config.IMAP_DEFAULT_PORT) }}

    {{ form.imap_user.label }}
    {%- if isnew %}
    {{ form.imap_user(placeholder=_("Leave empty to use list address")) }}
    {%- else %}
    {{ form.imap_user }}
    {%- endif %}

    {{ form.imap_pass.label }}
    {%- if isnew %}
    {{ form.imap_pass(placeholder=_("Leave empty to use configured default")) }}
    {%- else %}
    {{ form.imap_pass(placeholder=_("Leave empty to not update password")) }}
    {%- endif %}
  </details>

  <br />

  {{ form.submit(value=_('Save List')) }}
</form>

{% endmacro %}


{% macro subscriber_list_buttons(email) %}
{%- if is_email_a_list(email) %}
<p>
  <a href="{{ url_for('lists.edit', list_id=is_email_a_list(email).id) }}" role="button" class="">
    {{ _('Edit List Settings') }}
  </a>
  <a href="{{ url_for('lists.subscribers_manage', list_id=is_email_a_list(email).id) }}" role="button" class="secondary">
    {{ _('View List Subscribers') }}
  </a>
</p>
{%- endif %}
{% endmacro %}
