{% load comments i18n %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
  {% comment %}
  {% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
  {% endcomment %}

  <div><input type="hidden" name="next" value="{{ obj.get_absolute_url }}" /></div>
  {% for field in form %}
    {% if field.is_hidden %}
      <div>{{ field }}</div>
    {% else %}
      {% if field.errors %}{{ field.errors }}{% endif %}

      {% ifequal field.name "name" %}
      <input type="hidden" name="{{ field.name }}" id="id_{{field.name}}" value="{{ request.user.username }}" />
      {% endifequal %}

      {% ifequal field.name "email" %}
      <input type="hidden" name="{{ field.name }}" id="id_{{field.name}}" value="{% if request.user.email %}{{ request.user.email }} {% else %}anonymous@anonymous.com{% endif %}" />
      {% endifequal %}

      {% ifequal field.name "url" %}
      <input type="hidden" name="{{ field.name }}" id="id_{{ field.name }}" value="{{ request.user.person_set.all.0.get_absolute_url }}" />
      {% endifequal %}

      {% ifequal field.name "comment" %}
      <p>
        {{ field.label_tag }} {{ field }}
      </p>
      {% endifequal %}

      {% ifequal field.name "honeypot" %}
      <p style="display:none;">
        {{ field.label_tag }} {{ field }}
      </p>
      {% endifequal %}
    {% endif %}

  {% endfor %}
  <p class="submit">
    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
  </p>
</form>
