{% extends 'faq/question_base.html' %}

{% block question_content %}
{% if allow_multiple_answers %}
<h3>answers</h3>
<ul>
    {% for answer in question.answer_set.all %}
        <li><b>{{answer.answer}}</b>
            {% if can_vote_answer %}
             | found this answer helpful?
            <form style="display: inline;" action="{% if category_enabled %}{% url 'faq:vote_answer' question.category.slug question.slug answer.slug %}{% else %}{% url 'faq:vote_answer' question.slug answer.slug %}{% endif %}" method="post">
                {% csrf_token %}
                <input type="hidden" value=True name="vote">
                <button type="submit">yes({{answer.helpful}})</button>
            </form>
            <form style="display: inline;" action="{% if category_enabled %}{% url 'faq:vote_answer' question.category.slug question.slug answer.slug %}{% else %}{% url 'faq:vote_answer' question.slug answer.slug %}{% endif %}" method="post">
                {% csrf_token %}
                <input type="hidden" value=False name="vote">
                <button type="submit">no({{answer.not_helpful}})</button>
            </form>
            {% endif %}
        </li>
    {% endfor %}
</ul>

{% else %}
    {% if question.answer_set.exists %}
        <p>answer:</p>
        <h3>{{question.answer_set.first.answer}}</h3>
        {% if can_vote_answer %}
         found this answer helpful?
        <form style="display: inline;" action="{% if category_enabled %}{% url 'faq:vote_answer' question.category.slug question.slug question.answer_set.first.slug %}{% else %}{% url 'faq:vote_answer' question.slug question.answer_set.first.slug %}{% endif %}" method="post">
            {% csrf_token %}
            <input type="hidden" value=True name="vote">
            <button type="submit">yes({{question.answer_set.first.helpful}})</button>
        </form>
        <form style="display: inline;" action="{% if category_enabled %}{% url 'faq:vote_answer' question.category.slug question.slug question.answer_set.first.slug %}{% else %}{% url 'faq:vote_answer' question.slug question.answer_set.first.slug %}{% endif %}" method="post">
            {% csrf_token %}
            <input type="hidden" value=False name="vote">
            <button type="submit">no({{question.answer_set.first.not_helpful}})</button>
        </form>
        {% endif %}
    {% else %}
        no answers yet
    {% endif %}
{% endif %}


{% if can_answer_question %}
    {% if category_enabled %}
        <a href="{% url 'faq:answer_question' question.category.slug question.slug %}">answer question</a>
    {% else %}
        <a href="{% url 'faq:answer_question' question.slug %}">answer question</a>
    {% endif %}
{% endif %}
<hr>
{% if comments_allowed %}
    {% include 'faq/comments.html' %}
{% endif %}

{% endblock %}