{% load i18n %}
{% load comments %}

<form method="POST" autocomplete="off" action="{% comment_form_target %}" id="reply-form" style="display: none;">
  {% csrf_token %}
  {% for field in form %}
    {% if field.is_hidden %}{{ field }}{% endif %}
  {% endfor %}
  <input type="hidden" name="{{ comments_page_qs_param }}" value="" />
  <div class="hide">{{ form.honeypot }}</div>

  {% if 'comment' in form.errors %}
    <div data-dci="comment-form-errors" class="col1-2 alert alert-error">{{ form.errors.comment }}</div>
  {% else %}
    <div data-dci="comment-form-errors" class="col1-2 hide alert">{% if comment_form_errors %}{{ comment_form_errors }}{% endif %}</div>
  {% endif %}

  <div class="col1-2">
    {{ form.comment }}
  </div>

  {% if not request.user.is_authenticated or not request.user.get_full_name %}
    <label for="id_name" class="col1">{{ form.name.label }}</label>
    <div class="col2 {% if 'name' in form.errors %}error{% endif %}">
      {{ form.name }}
    </div>
    {% if 'name' in form.errors %}
      <div class="col2 helper-text error">{{ form.errors.name.0 }}</div>
    {% endif %}
  {% endif %}

  {% if not request.user.is_authenticated or not request.user.email %}
    <label for="id_email" class="col1">{{ form.email.label }}</label>
    <div class="col2 {% if 'email' in form.errors %}error{% endif %}">
      {{ form.email }}
    </div>
    {% if 'email' in form.errors %}
      <div class="col2 helper-text error">{{ form.errors.email.0 }}</div>
    {% else %}
      <div class="col2 helper-text">{% url 'login' as login_url %}{% blocktrans %}Required for comment verification. Otherwise <a href="{{ login_url }}">login</a>.{% endblocktrans %}</div>
    {% endif %}
  {% endif %}

  {% if not request.user.is_authenticated %}
    <label for="id_url" class="col1">{{ form.url.label }}</label>
    <div class="col2 {% if 'url' in form.errors %}error{% endif %}">
      {{ form.url }}
    </div>
  {% endif %}

  <div class="col2">
    {{ form.followup }}
    <label for="id_followup{% if cid %}_{{ cid }}{% endif %}">&nbsp;{{ form.followup.label }}</label>
  </div>

  <div class="col2">
    <div class="inline-left">
      <button type="button" class="primary small" name="post" value="1">{% trans 'send' %}</button>&nbsp;
      <button type="button" class="secondary small" name="preview" value="1">{% trans 'preview' %}</button>&nbsp;
      <button type="button" class="secondary small" name="cancel">{% trans 'cancel' %}</button>
    </div>
  </div>
</form>
