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

{% block sub_title %}{% if poster == request.user %}{% trans "My messages" %}{% else %}{% blocktrans with username=poster|forum_member_display_name %}{{ username }}'s posts{% endblocktrans %}{% endif %}{% endblock sub_title %}

{% block content %}
<div class="row">
  <div class="col-12">
    <h1>{% if poster == request.user %}{% trans "My messages" %}{% else %}{% blocktrans with username=poster|forum_member_display_name %}{{ username }}'s posts{% endblocktrans %}{% endif %}</h1>
  </div>
</div>
<div class="row">
  <div class="col-6 col-md-4 forum-actions-block">
    {% if paginator.count > 0 %}
    <p class="mt-1 mb-0 text-muted">
      {% blocktrans trimmed count counter=paginator.count %}
      {{ counter }} post found
      {% plural %}
      {{ counter }} posts found
      {% endblocktrans %}
    </p>
    {% else %}
    <p class="mt-1 mb-0 text-muted">{% trans "No posts found" %}</p>
    {% endif %}
  </div>
  <div class="col-12 col-md-8 pagination-block">
    {% with "pagination-sm justify-content-end" as pagination_size %}
    {% include "partials/pagination.html" %}
    {% endwith %}
  </div>
</div>
<div class="row member-posts">
  <div class="col-12">
    {% for post in posts %}
    <div id="{{ post.id }}" class="my-3 card post">
      <div class="card-body">
        <div class="row">
          <div class="col-md-10 post-content-wrapper">
              {% spaceless %}
              <h4 class="subject">
                <a href="{% url 'forum_conversation:topic' post.topic.forum.slug post.topic.forum.pk post.topic.slug post.topic.pk %}?post={{ post.pk }}#{{ post.pk }}">{{ post.subject }}</a>
              </h4>
              {% endspaceless %}
              <p>
                <small class="text-muted">
                {% spaceless %}
                <i class="fas fa-clock"></i>&nbsp;
                {% 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 %}
                {% endspaceless %}
                </small>
              </p>
              <div class="post-content">
                {{ post.content.rendered|truncatechars_html:250 }}
              </div>
          </div>
          <div class="col-md-2 post-sidebar">
            <div class="avatar">
              <a href="{% url 'forum_member:profile' post.poster_id %}">
                {% include "partials/avatar.html" with profile=post.poster placeholder=False %}
              </a>
            </div>
            <div class="username"><a href="{% url 'forum_member:profile' post.poster_id %}"><b>{{ post.poster|forum_member_display_name }}</b></a></div>
            <div class="posts-count text-muted"><b>{% trans "Posts:" %}</b>&nbsp;{{ post.poster.forum_profile.posts_count }}</div>
          </div>
        </div>
      </div>
    </div>
    {% endfor %}
  </div>
</div>
<div class="row">
  <div class="col-12 pagination-block">
    {% with "pagination-sm justify-content-end" as pagination_size %}
      {% include "partials/pagination.html" %}
    {% endwith %}
  </div>
</div>
{% endblock content %}
