{% load helpers %}

{% if questions %}
<br>
<table class="table table-striped table-bordered table-hover">
    <th> FOSS </th>
    <th> Tutorial</th>
    <th> Min </th>
    <th> Sec </th>
    <th> Question</th>
    <th> Date</th>
    <th> Views</th>
    <th> Answers</th>
    <th> User</th>
    {% for question in questions %}
    <tr>
        <td>
            <span href="#" class="category" data-toggle="tooltip" data-placement="top" title="{{ question.category}}">
                {{ question.category|truncatechars:12 }} 
            </span>
            <a class="pull-right" href="{% url 'website:filter' question.category %}?qid={{ question.id }}">
                <span class="glyphicon glyphicon-search"></span>
            </a>
        </td>

        <td>
            <span class="tutorial" data-toggle="tooltip" data-placement="top" title="{{ question.tutorial}}">
                {{ question.tutorial|truncatechars:12 }}
            </span>
            <a class="pull-right" href="{% url 'website:filter' question.category question.tutorial %}?qid={{ question.id }}">
                <span class="glyphicon glyphicon-search"></span>
            </a>
        </td>

        <td>
            <span>
                <a href="{% url 'website:filter' question.category question.tutorial question.minute_range %}?qid={{ question.id }}">
                    {{ question.minute_range }}
                </a>
            </span>
        </td>

        <td>        
            <span>
                <a href="{% url 'website:filter' question.category question.tutorial question.minute_range question.second_range%}?qid={{ question.id }}">
                    {{ question.second_range }}
                </a>
            </span>
        </td>

        <td>
            <span class="title" data-toggle="tooltip" data-placement="top" title="{{ question.title }}">
                <a href="{% url 'website:get_question' question.id %}{% prettify question.title %}">{{ question.title|truncatechars:40 }}</a>
            </span>            
        </td>

        <td>    
            <span>
                <i>
                    {{ question.date_created|date:"d-m-y" }}
                </i>
            </span>
        </td>

        <td>
            {{ question.views}}
        </td>

        <td>
            {{ question.answer_set.count }}
        </td>

        <td>
                <span class="title" data-toggle="tooltip" data-placement="top" title="{{ question.user }}">
                {{ question.user|truncatechars:10 }}
            </span>
        </td>

    </tr>
    {% endfor %}
</table>
{% else %}
    <h4>No results found . . .</h4>
{% endif %}

{% block javascript %}
<script>
    $('span').tooltip();
</script>
{% endblock %}