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

{% block sub_title %}{% trans "Post a reply" %}{% endblock sub_title %}

{% block content %}
<div class="row">
  <div class="col-12">
    <h1>{{ topic.subject }}</h1>
  </div>
</div>
<div class="row">
  <div class="col-12">
    <div class="card post-edit">
      <div class="card-header">
        <h3 class="m-0 h5 card-title">{% trans "Post a reply" %}</h3>
      </div>
      <div class="card-body">
        <form method="post" action="." class="form" enctype="multipart/form-data" novalidate>{% csrf_token %}
          {% include "forum_conversation/partials/post_form.html" %}
          <div class="form-actions">
            <input type="submit" class="btn btn-large btn-primary" value="{% trans "Submit" %}" />
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<div class="mt-3 row">
  <div class="col-12">
    <div class="card topic-review">
      <div class="card-header">
        <h3 class="m-0 h5 card-title">{% trans "Topic review" %}&nbsp;&ndash;&nbsp;{{ topic.subject }}</h3>
      </div>
      <div class="card-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|forum_member_display_name%}
                  By: <a href="{{ poster_url }}">{{ username }}</a> 
                {% endblocktrans %}
                {% include "partials/user_icon.html" with topic=post.topic user=post.poster %}
                {% blocktrans trimmed  with creation_date=post.created %}
                  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|forum_member_display_name }}</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 %}
