{% extends 'users/base.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block title %}User Profile{% endblock %}

{% block content %}
  <div class="row mb-3">
    <div class="col-md-6">
      <div class="card">
        <h5 class="card-header">Account Details</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <th scope="row">Username</th>
              <td>{{ request.user.username }}</td>
            </tr>
            <tr>
              <th scope="row">Full Name</th>
              <td>
                {% if request.user.first_name or request.user.last_name %}
                  {{ request.user.first_name }} {{ request.user.last_name }}
                {% else %}
                  <span class="text-muted">&mdash;</span>
                {% endif %}
              </td>
            </tr>
            <tr>
              <th scope="row">Email</th>
              <td>{{ request.user.email|placeholder }}</td>
            </tr>
            <tr>
              <th scope="row">Account Created</th>
              <td>{{ request.user.date_joined|annotated_date }}</td>
            </tr>
            <tr>
              <th scope="row">Superuser</th>
              <td>{% checkmark request.user.is_superuser %}</td>
            </tr>
            <tr>
              <th scope="row">Admin Access</th>
              <td>{% checkmark request.user.is_staff %}</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <div class="col-md-6">
      <div class="card">
        <h5 class="card-header">Assigned Groups</h5>
        <ul class="list-group list-group-flush">
          {% for group in request.user.groups.all %}
            <li class="list-group-item">{{ group }}</li>
          {% empty %}
            <li class="list-group-item text-muted">None</li>
          {% endfor %}
        </ul>
      </div>
    </div>
  </div>
  {% if perms.extras.view_objectchange %}
    <div class="row">
      <div class="col-md-12">
        <div class="card">
          <h5 class="card-header text-center">Recent Activity</h5>
          <div class="card-body table-responsive">
            {% render_table changelog_table 'inc/table.html' %}
          </div>
        </div>
      </div>
    </div>
  {% endif %}
{% endblock %}
