{% load dialogos_tags %}
{% load bootstrap_tags %}
{% load pagination_tags %}
{% load url from future %}
{% load friendly_loader %}
{% load i18n %}
{% friendly_load avatar_tags %}

{% load i18n %}
<div id="comments_section" class="comments paginate paginate-manual">
  <header>
    <h3>{% trans 'Comments' %} <span class="total">({% comment_count obj %} total)</span></h3>
  </header>

  {% if user.is_authenticated %}
  <div class="clearfix">
    <a href="#form_post_comment_div" role="button" class="btn pull-right" data-toggle="modal">{% trans 'Add Comment' %}</a>
  </div>
  {% else %}
  <div class="clearfix">
    <p class="pull-right">{% trans 'Log in to add a comment' %}</p>
  </div>
  {% endif %}
  <div class="paginate-contents">
  {% comments obj as comment_list %}
  {% autopaginate comment_list 5 %}
  {% for comment in comment_list %}      
    <article>
      <div class="avatar span1"><a href="{{ comment.author.get_profile.get_absolute_url }}">{% avatar comment.author 40 %}</a></div>
      <div class="pull-left span7">
        <p>{{ comment.comment }}</p>
        <footer>
          <div class="author clearfix span7">
            <p>{% trans 'By' %} <a href="{{ comment.author.get_profile.get_absolute_url }}" rel="author">{{ comment.author }}</a> on <time>{{ comment.submit_date|date:"M j, Y" }}</time></p>
          </div>
        </footer>
      </div>
    </article>
  {% endfor %}
  </div>
  {% paginate %}
</div>

<!-- Modal -->
{% if user.is_authenticated %}
<div id="form_post_comment_div" class="modal hide fade" tabindex="-1" role="dialog">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3>{% trans 'Add a Comment' %}</h3>
    </div>
    <div class="modal-body">
        {% comment_form obj as form %}
        <form action="{% comment_target obj %}" method="POST" id="form_post_comment">
        {% csrf_token %}
        {{ form }}
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
        <button id="comment_submit_btn" class="btn btn-primary">{% trans 'Submit Comments' %}</button>
    </div>
        </form>
</div>
{% endif %}
