{% load i18n pybb_tags staticfiles %}

{% pybb_get_profile user=post.user as post_user_profile %}
{% pybb_get_profile user=user as user_profile %}

<a name="post-{{ post.id }}"></a> {# may be remove this string? #} 
<table class="table table-bordered post {% if post.on_moderation %}on-moderation{% endif %}" id="post-{{ post.id }}">
    <thead class="post-header">
    <tr>
    <th colspan="2">
        <a class="permalink" href="{{ post.get_absolute_url }}">#</a>
        <span class="updated">{% pybb_time post.created %}</span>
    </th>
    </tr>
    </thead>
    <tbody>
    <tr class="post-row">
        <td class="post-info">
            {% include "pybb/avatar.html" with user=post.user %}

            <div class="post-author">
                <a href="{{ post_user_profile.get_absolute_url }}">
                    <span class="post-username">{{ post_user_profile.get_display_name }}</span>
                </a>
            </div>
            {% if post_user_profile.rank %}
                <div class="rank">
                    {% blocktrans with rank=post_user_profile.rank %}Rank: {{ rank }}{% endblocktrans %}
                    {% if user.is_authenticated and user ! = post.user %}
                        <a href="#" class="vote" rel="{{ post_user_profile.get_vote_up_url }}">+</a>
                        <a href="#" class="vote" rel="{{ post_user_profile.get_vote_down_url }}">-</a>
                    {% endif %}
                </div>
            {% endif %}
            {% if user.is_superuser %}
                <div class="post-extra-info">{{ post.user_ip }}</div>
            {% endif %}

            <div class="post-controls">
                {% if user|pybb_may_edit_post:post %}
                    <a href="{% url 'pybb:edit_post' pk=post.id %}">{% trans 'Edit' %}</a>
                {% endif %}
                {% if user|pybb_may_delete_post:post %}
                    <a onclick="pybb_delete_post('{% url 'pybb:delete_post' post.id %}',
                            'post-{{ post.id }}', '{% trans 'Delete post?'  as txt %}{{ txt|escapejs }}'); return false;"
                       href="{% url 'pybb:delete_post' post.id %}">{% trans 'Delete' %}</a>
                {% endif %}
                {% if post.on_moderation and user.is_moderator %}
                    <a href="{% url 'pybb:moderate_post' pk=post.id %}">{% trans 'Approve post' %}</a>
                {% endif %}
                {% if user.is_moderator %}
                    <a href="{% url 'pybb:move_post' pk=post.id %}">{% if post.is_topic_head %}{% trans 'Move' %}{% else %}{% trans "Split" %}{% endif %}</a>
                {% endif %}

                {% if user|pybb_may_admin_post:post %}
                    <a href="{% url 'admin:pybb_post_change' post.id %}">{% trans 'Admin' %}</a>
                {% endif %}

            </div>
        </td>
        <td class="post-content">
            {{ post.body_html|safe }}

            {% if not user.is_authenticated or user_profile.show_signatures %}
                {% if post_user_profile.signature %}
                    <div class="post-signature">
                        {{ post_user_profile.signature_html|safe }}
                    </div>
                {% endif %}
            {% endif %}
            {% if post.updated %}
                <div class="updated-message">{% trans 'Edited' %} {% pybb_time post.updated %}</div>
            {% endif %}

            {% comment %}
                    {% if post.attachment_cache %}
                    {% for attach in post.attachment_cache %}
                    <br/>
                    {% trans 'Attachment' %}{% trans ':' %} <a href="{{ attach.get_absolute_url }}">{{ attach.name }}</a> ({{ attach.size_display }})
                    {% endfor %}
                    {% endif %}
            {% endcomment %}
            <div class="post-related">
                {% if user|pybb_may_create_post:post.topic %}
                    <a href="{% url 'pybb:add_post' topic.id %}? quote_id={{ post.id }}" class="quote-link">{% trans 'quote' %}</a>
                    <a href="#" class="quote-selected-link">{% trans 'quote selected' %}</a>
                {% endif %}
                <div class="attachments">
                    {% for attachment in post.attachments.all %}
                        <a href="{{ attachment.file.url }}"><img src="{% static 'pybb/img/attachment.png' %}"> {{ attachment.size_display }}</a>
                    {% endfor %}
                </div>
            </div>
        </td>
    </tr>
    </tbody>
</table>
