{% extends "base.html" %}

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

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_absolute_url }}">{% trans 'Back to the pool' %}</a>
    {%  if question_list|length > 1 %}
        <a href="{{ pool.get_questions_sort_url }}" class="btn btn-primary">
            <i class="fa fa-sort"></i> {% trans "Sort questions" %}
        </a>
    {% endif %}
    <a href="{{ pool.get_questions_create_url }}" class="btn btn-primary">
        <i class="fa fa-plus"></i> {% trans "Add a question" %}
    </a>
{% endblock %}

{% block main %}
<table class="table table-hover">
    <thead>
        <tr>
            <th>{% trans 'Title'%}</th>
            <th>{% trans 'Type'%}</th>
            <th>{% trans 'Value type'%}</th>
            <th>{% trans 'Edit' %}</th>
            <th>{% trans 'Delete' %}</th>
        </tr>
    </thead>
    <tbody>
        {% for question in question_list %}
            <tr>
                <td>{{ question.title }}</td>
                <td>{{ question.get_question_type_display }}</td>
                <td>{{ question.get_value_type_display }}</td>

                <td><a class="btn btn-default" href="{{ question.get_absolute_url }}" title="{% trans 'Edit' %}"><i class="fa fa-pencil"></i></a></td>
                <td><a class="btn btn-danger" href="{{ question.get_delete_url }}" title="{% trans 'Delete' %}"><i class="fa fa-trash"></i></a></td>
            </tr>
        {% endfor %}
    </tbody>
</table>

{% endblock %}
