{% extends 'settings/layout.html' %}
{% load i18n %}
{% load humanize %}
{% load utilities %}
{% load feed_page_tags %}

{% block title %}
{% include "settings/reports/report_header.html" with report=report %}
{% endblock %}

{% block header %}
{% include "settings/reports/report_header.html" with report=report %}
<a href="{% url 'settings-reports' %}" class="has-text-weight-normal help">{% trans "Back to reports" %}</a>
{% endblock %}

{% block panel %}

<div class="block">
    {% include 'settings/reports/report_preview.html' with report=report %}
</div>

<div class="block">
    <details class="details-panel box">
        <summary>
            <span class="title is-6">{% trans "Message reporter" %}</span>
            <span class="details-close icon icon-x" aria-hidden="true"></span>
        </summary>
        <div class="box">
            {% trans "Update on your report:" as dm_template %}
            {% include 'snippets/create_status/status.html' with type="direct" uuid=1 mention=report.reporter prepared_content=dm_template no_script=True %}
        </div>
    </details>
</div>

{% if report.status %}
<div class="block">
    <h3 class="title is-4">{% trans "Reported status" %}</h3>
    {% if report.status.deleted %}
    <em>{% trans "Status has been deleted" %}</em>
    {% else %}
    {% include 'snippets/status/status.html' with status=report.status|load_subclass moderation_mode=True %}
    {% endif %}
</div>
{% endif %}

{% if report.links.exists %}
<div class="block">
    <h3 class="title is-4">{% trans "Reported links" %}</h3>
    <div class="card block">
        <div class="card-content content">
            <div class="table-container">
                {% include "settings/reports/report_links_table.html" with links=report.links.all %}
            </div>
        </div>
    </div>
</div>
{% endif %}

{% if report.user %}
{% include 'settings/users/user_info.html' with user=report.user %}

{% include 'settings/users/user_moderation_actions.html' with user=report.user %}
{% endif %}

<div class="block content">
    <h3 class="title is-4">{% trans "Moderation Activity" %}</h3>

    <div class="box">
        <ul class="mt-0">
            <li class="mb-2">
                <div class="is-flex">
                    <p class="mb-0 is-flex-grow-1">
                        {% blocktrans trimmed with user=report.reporter|username user_link=report.reporter.local_path %}
                        <a href="{{ user_link }}">{{ user}}</a> opened this report
                        {% endblocktrans %}
                    </p>
                    <span class="tag">{{ report.created_date }}</span>
                </div>
            </li>

            {% for comment in report.reportaction_set.all %}
            <li class="mb-2">
                <div class="is-flex">
                    <p class="mb-0 is-flex-grow-1">
                        {% if comment.action_type == "comment" %}
                            {% blocktrans trimmed with user=comment.user|username user_link=comment.user.local_path %}
                            <a href="{{ user_link }}">{{ user}}</a> commented on this report:
                            {% endblocktrans %}
                        {% else %}
                            {% blocktrans trimmed with user=comment.user|username user_link=comment.user.local_path %}
                            <a href="{{ user_link }}">{{ user}}</a> took an action on this report:
                            {% endblocktrans %}
                            <span class="has-text-weight-bold">
                                {{ comment.get_action_type_display }}
                            </span>
                        {% endif %}
                    </p>
                    <span class="tag">{{ comment.created_date }}</span>
                </div>

                {% if comment.note %}
                <blockquote>{{ comment.note }}</blockquote>
                {% endif %}
            </li>
            {% endfor %}
        </ul>

        <form class="block" name="report-comment" method="post" action="{% url 'settings-report' report.id %}">
            {% csrf_token %}
            <div class="field">
                <label for="report_comment" class="label">Comment on report</label>
                <textarea name="note" id="report_comment" class="textarea"></textarea>
            </div>
            <div class="field">
                <button class="button">{% trans "Comment" %}</button>
            </div>
        </form>
    </div>
</div>
{% endblock %}
