{% load i18n cms_tags %}
{% load url from future %}

{% regroup object_list|dictsort:"category_id" by category as qgroups %}

<div class="panel panel-primary">
    {% for qgroup in qgroups %}
        {% if list %}
            <div class="panel-heading">
                <h3 class="panel-title">{{ qgroup.grouper }}</h3>
            </div>
        {% endif %}
        <div class="list-group">
            {% for question in qgroup.list %}
                <a href="{% url 'aldryn_faq:faq-answer' question.category.slug question.pk %}" class="list-group-item">
                    {% render_model question "title" %}
                    {% if not list %}<span class="badge">{{ qgroup.grouper }}</span>{% endif %}
                </a>
            {% endfor %}
        </div>
    {% empty %}
        {% if list %}
            <div class="panel-heading">
                <h3 class="panel-title">{{ qgroup.grouper|default:_("Category") }}</h3>
            </div>
        {% endif %}
        <div class="list-group">
            <p class="list-group-item">{% trans "No entry found." %}</p>
        </div>
    {% endfor %}
</div>

{% if list and title %}
    {% url 'aldryn_faq:faq-category' object.category.slug as category_url %}
    {% include "aldryn_faq/includes/pager.html" with title=_("Back to Category") slug=category_url %}
{% endif %}
