{% extends "base.html" %}

{% comment %}This view is used to sort a list of ``mtp.apps.surveys.Question`` instances of  a pool..

It includes ``cms/includes/orderable-head.html`` for the sortable logic in javascript,
with the table listing questions having the ``orderable`` class, and displaying the
``sort_order_display`` attribute of the questions.

New order is saved via ajax after each change.

Context
-------
pool : instance of ``mtp.apps.surveys.models.Pool``
    The pool for which we display the questions.
question_list : queryset of ``mtp.apps.surveys.models.Question``
    It contains all the questions to display.

{% endcomment %}

{% load i18n %}

{% block body_class %}{{ block.super }} page-cms-surveys page-cms-surveys-questions{% endblock %}

{% block subtitle %}
    {% blocktrans with pool_name=pool.name %}Questions for the pool of question "{{ pool_name }}"{% endblocktrans %}
{% endblock %}

{% block actions %}
    <a class="btn btn-default" href="{{ pool.get_questions_list_url }}">{% trans 'Back to the list of questions' %}</a>
    <a class="btn btn-default" href="{{ pool.get_absolute_url }}">{% trans 'Back to the pool' %}</a>
{% endblock %}

{% block head %}
    {{ block.super }}
    {% include "cms/includes/orderable-head.html" %}
{% endblock %}

{% block main %}
<table class="table table-hover table-striped orderable">{% csrf_token %}
    <thead>
        <tr>
            <th>{% trans 'Title'%}</th>
            <th class="orderable-message-holder">{% trans 'Order' %}</th>
        </tr>
    </thead>
    <tbody>
        {% for question in question_list %}
            <tr>
                <td>{{ question.title }}</td>
                <td>{{ question.sort_order_display|safe }}</td>
            </tr>
        {% endfor %}
    </tbody>
</table>

{% endblock %}
