{% load static i18n  jazzmin admin_urls ra_admin_tags %}
{% if jazzmin_settings.show_sidebar %}
    {% get_side_menu as side_menu_list %}

    <aside class="main-sidebar elevation-4 {{ jazzmin_ui.sidebar_classes }}" id="jazzy-sidebar">
        <a href="{% url 'admin:index' %}" class="brand-link {{ jazzmin_ui.brand_classes }}" id="jazzy-logo">
            <img src="{% static jazzmin_settings.site_logo %}" alt="{{ jazzmin_settings.site_header }} Logo"
                 class="brand-image img-circle elevation-3" style="opacity: .8">
            <span class="brand-text font-weight-light">{{ jazzmin_settings.site_header }}</span>
        </a>

        <div class="sidebar">
            <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <div class="image">
                    {% if jazzmin_settings.user_avatar %}
                        <img src="{% get_user_avatar request.user %}" width="160px" class="img-circle elevation-2"
                             alt="User Image">
                    {% else %}
                        <i class="fas fa-inverse user-profile fa-user-circle"></i>
                    {% endif %}
                </div>
                <div class="info">
                    {% if perms|can_view_self %}
                        <a href="{% jazzy_admin_url request.user %}" class="d-block">{{ request.user }}</a>
                    {% else %}
                        <span class="d-block" style="color: white;">{{ request.user }}</span>
                    {% endif %}
                </div>
            </div>

            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column {{ jazzmin_ui.sidebar_list_classes }}"
                    data-widget="treeview" role="menu" data-accordion="false">

                    <li class="nav-item">
                        <a href="{% url 'admin:index' %}" class="nav-link">
                            <i class="nav-icon fas fa-tachometer-alt"></i>
                            <p>{% trans 'Dashboard' %}</p>
                        </a>
                    </li>

                    {% render_navigation_menu %}

{#                    {% if jazzmin_settings.navigation_expanded %}#}
{#                        {% for app in side_menu_list %}#}
{#                            <li class="nav-header">{{ app.name }}</li>#}
{#                            {% for model in app.models %}#}
{#                                <li class="nav-item">#}
{#                                    <a href="#}
{##}
{##}
{#                                            {% if model.admin_url %}{{ model.admin_url }}{% else %}javascript:void(0){% endif %}"#}
{#                                       class="nav-link">#}
{#                                        <i class="fa nav-icon {% if model.icon %} {{ model.icon }} {% else %}fa-circle{% endif %}"></i>#}
{#                                        <p>{{ model.name }}</p>#}
{#                                    </a>#}
{#                                </li>#}
{#                            {% endfor %}#}
{#                        {% endfor %}#}
{#                    {% else %}#}
{#                        {% for app in side_menu_list %}#}
{#                            <li class="nav-item has-treeview">#}
{#                                <a href="#" class="nav-link">#}
{#                                    <i class="nav-icon fas {% if model.icon %} {{ model.icon }} {% else %}fa-circle{% endif %}"></i>#}
{#                                    <p>{{ app.name|truncatechars:21 }} <i class="fas fa-angle-left right"></i></p>#}
{#                                </a>#}
{#                                <ul class="nav nav-treeview" style="display: none;">#}
{#                                    {% for model in app.models %}#}
{#                                        <li class="nav-item">#}
{#                                            <a href="#}
{##}
{##}
{#                                                    {% if model.admin_url %}{{ model.admin_url }}{% else %}javascript:void(0){% endif %}"#}
{#                                               class="nav-link">#}
{#                                                <i class="fa nav-icon {% if model.icon %} {{ model.icon }} {% else %}fa-circle{% endif %}"></i>#}
{#                                                <p>{{ model.name }}</p>#}
{#                                            </a>#}
{#                                        </li>#}
{#                                    {% endfor %}#}
{#                                </ul>#}
{#                            </li>#}
{#                        {% endfor %}#}
{#                    {% endif %}#}
                    {% if user.is_authenticated %}
                        {% render_reports_menu %}
                    {% endif %}
                </ul>
            </nav>
        </div>
    </aside>
{% endif %}
