{% extends 'board_base.html' %}
{% load i18n %}
{% load forum_conversation_tags %}

{% block sub-title %}{% trans "Post a reply" %}{% endblock sub-title %}

{% block content %}
    <div class="row">
        <div class="col-xs-12">
            <h1>{{ topic.subject }}</h1>
        </div>
    </div>
    {% if preview %}
        {% include "forum_conversation/post_preview.html" %}
    {% endif %}
    <div class="row">
        <div class="col-xs-12">
            <div class="panel panel-default post-edit">
                <div class="panel-heading">
                    <h3 class="panel-title">{% trans "Post a reply" %}</h3>
                </div>
                <div class="panel-body">
                    <form method="post" action="." class="form" enctype="multipart/form-data" novalidate>{% csrf_token %}
                        {% include "forum_conversation/partials/post_form.html" %}
                        {% if attachment_formset %}
                            <div class="form-group">
                                <div class="row">
                                    <div id="attachment_formset" class="col-md-12">
                                         <p class="lead attachments-title">{% trans "Attachments" %}</p>
                                        {% include "forum_conversation/forum_attachments/attachment_formset.html" %}
                                    </div>
                                </div>
                            </div>
                        {% endif %}
                        <div class="form-actions">
                            <input type="submit" name="preview" class="btn btn-large btn-default" value="{% trans "Preview" %}" />&nbsp;
                            <input type="submit" class="btn btn-large btn-primary" value="{% trans "Submit" %}" />
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <div class="panel panel-default topic-review">
                <div class="panel-heading">
                    <h3 class="panel-title">{% trans "Topic review" %}&nbsp;&ndash;&nbsp;{{ topic.subject }}</h3>
                </div>
                <div class="panel-body">
                    {% for post in previous_posts %}
                        <div class="row post-review">
                            <div class="col-md-10 post-content-wrapper">
                                <h4 class="subject">{{ post.subject }}</h4>
                                <p><small class="text-muted">
                                  {% spaceless %}
                                    <i class="fa fa-clock-o"></i>&nbsp;
                                    {% if post.poster %}
                                      {% url 'forum_member:profile' post.poster_id as poster_url %}
                                      {% blocktrans trimmed with poster_url=poster_url username=post.poster.username creation_date=post.created %}
                                        By: <a href="{{ poster_url }}">{{ username }}</a> on {{ creation_date }}
                                      {% endblocktrans %}
                                    {% else %}
                                      {% blocktrans trimmed with poster_username=post.username creation_date=post.created %}
                                        By: {{ poster_username }} on {{ creation_date }}
                                      {% endblocktrans %}
                                    {% endif %}
                                  {% endspaceless %}
                                </small></p>
                                <div class="post-content">
                                    {{ post.content.rendered }}
                                </div>
                                {% include "forum_conversation/forum_attachments/attachments_detail.html" %}
                            </div>
                            <div class="col-md-2 post-sidebar">
                                <div class="username">{% if post.poster %}<a href="{% url 'forum_member:profile' post.poster_id %}"><b>{{ post.poster.username }}</b></a>{% else %}<b>{{ post.username }}</b>{% endif %}</div>
                            </div>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
{% endblock content %}

{% block onbodyload %}
    machina.attachment.init();
{% endblock onbodyload %}

{% block extra_css %}
    {{ post_form.media.css }}
{% endblock extra_css %}

{% block extra_js %}
    {{ post_form.media.js }}
{% endblock extra_js %}
