{% extends 'musette/base_musette.html' %}

{% load i18n %}
{% load static %}
{% load forum_tags %}

{% block content %}

<div class="container">
    <div class="row">
        <div class="col-md-2 bg_blur">

            <img src="{{photo}}" class="img-thumbnail picture hidden-xs" width="200" hegiht="200" />

            {% if user != profile.iduser %}
                {% if not profile.iduser.is_superuser and profile.iduser|get_total_forum_moderator == 0 %}
                    {% if user|get_total_forum_moderator > 0 or user.is_superuser %}
                        {% if not profile.is_troll %}
                            <form method="POST" action="{% url 'profile_is_troll' %}">{% csrf_token %}
                                <input type="hidden" name="username" value="{{ profile.iduser }}" />
                                <input type="hidden" name="check" value="1" />
                                <button type="submit" class="btn btn-sm btn-default" style="margin-top: 10px">{% trans "Is troll" %}</button>
                            </form>
                        {% endif %}
                    {% endif %}
                {% endif %}
            {% endif %}

            {% if profile.is_troll %}
                <p style="margin-top: 10px"> <strong><u>{% trans "It is a troll" %}</u></strong> </p>

                {% if user != profile.iduser and user.is_superuser %}
                    <form method="POST" action="{% url 'profile_is_troll' %}">{% csrf_token %}
                        <input type="hidden" name="username" value="{{ profile.iduser }}" />
                        <input type="hidden" name="check" value="0" />
                        <button type="submit" class="btn btn-sm btn-default" style="margin-top: 10px">{% trans "It is not a troll" %}</button>
                    </form>
                {% endif %}
            {% endif %}

            <div class="header">
                <h1>{{ profile.iduser.first_name }} {{ profile.iduser.last_name }}</h1>
                <h5><b>{% trans "Joined" %}</b> {{ profile.iduser.date_joined.date }}</h5>
                <table>
                    <tr>
                        <td>
                            <b>{% trans "Last Seen" %}</b>
                            {% if profile.last_seen %}
                                {{ profile.last_seen|timesince }}
                            {% else %}
                                {% trans "a while ago" %}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>
                            {% if profile.online %}
                                <div class="label label-success"><b>Online</b></div>
                            {% else %}
                                <div class="label label-danger"><b>Offline</b></li></div>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>

            {% if profile.iduser.id == user.id and not profile.is_troll %}
                <br>
                <button onclick="document.location = '{% url 'edit_profile' profile.iduser.username %}'" class="btn btn btn-inverse">{% trans "Edit profile" %}</button>
            {% endif %}

        </div>
        <div class="col-md-9  col-xs-12">

            <h4>{% trans "About me" %}</h4>
            <div class="panel panel-default">
                <div class="panel-body">
                    {{ profile.about|default_if_none:''|safe }}
                </div>
            </div>

            {% if model_profile_is_extend %}
                {% with app|add:"/profile.html" as template %}
                    {% include template %}
                {% endwith %}
            {% endif %}
        </div>
    </div>

    <br />

    {% if topics %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
                <tr>
                <th><i class="fa fa-map-o" aria-hidden="true"></i> {% trans "Title" %}</th>
                <th><i class="fa fa-square"></i> {% trans "Forum" %}</th>
                <th><i class="fa fa-history" aria-hidden="true"></i> {% trans "Date" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for topic in topics %}
                <tr>
                    <td> <a href="{% url 'topic' topic.forum.category topic.forum topic.slug topic.pk %}"> {{ topic.title }} </a> </td>
                    <td> <a href="{% url 'forum' topic.forum.category topic.forum  %}">{{topic.forum.name }} </a></td>
                    <td> {{topic.date.date }} </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}
</div> 

{% endblock %}