{% 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>
{% if preview %}
  {% include "forum_conversation/post_preview.html" %}
{% endif %}
<div>
  <div class="w-full rounded border bg-charcoal/60 border-1 border-slate">
    <div class="card post-edit">
      <div class="py-2 px-4 border-b card-header border-slate">
        <h3 class="m-0 text-base h5 card-title">{% trans "Post a reply" %}</h3>
      </div>
      <div class="p-4 card-body">
        <form method="post" action="." class="space-y-4 form" enctype="multipart/form-data" novalidate>{% csrf_token %}
          {% include "forum_conversation/partials/post_form.html" %}
          <div class="pt-6 form-actions">
            <input type="submit" name="preview" class="py-3 px-8 text-sm text-base font-medium uppercase rounded-md border md:py-1 md:px-4 md:text-lg border-slate text-orange" value="{% trans "Preview" %}" />&nbsp;
            <input type="submit" class="py-3 px-8 text-sm text-base font-medium uppercase rounded-md border md:py-1 md:px-4 md:text-lg border-orange text-orange" 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 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|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 %}
