{% load comments mptt_tags molo_commenting_tags %}

{% if self.is_commenting_enabled %}
<div class="block comment__form">
  {% if self.allow_commenting %}
    {% get_comment_count for self as comment_count %}
    {% if comment_count > 0 %}
    <h6 class="comment__text">
      {{comment_count}} {% blocktrans count comment_count=comment_count %}comment{% plural %}comments{% endblocktrans %}
    </h6>
    {% endif %}
    <div class="comment__form-post">
    {% if request.user.is_authenticated %}
      {% render_comment_form for self %}
    {% else %}
      <a href="{{ LOGIN_URL }}?next={{request.path}}" class="button inverted">{% trans "Log in to comment" %}</a>
    {% endif %}
  {% else %}
    <p>{% trans "Commenting on this article is currently disabled" %}</p>
  {% endif %}
	</div>
</div>

<div id="comments-list" class="comments__list">
  {% get_comment_count for self as comment_count %}
    {% get_molo_comments for self as comment_list limit 2 child_limit 2 %}
      {% for node in comment_list %}
        {% recursetree node %}
             {% include "comments/comment.html" with truncate_comment=True %}
            {{ children }}
        {% endrecursetree %}
      {% endfor %}
      {% if comment_count > 2 %}
        <div class="pagination">
          <a href="{% url 'molo.commenting:more-comments' self.pk %}" class="call-to-action__hyperlink">{% trans "View more comments" %}</a>
        </div>
      {% endif %}
</div>
{% endif %}
