{% set page_title = _("Banned Users") %}
{% set active = "management.users" %}

{% extends theme("management/management_layout.html") %}

{% block breadcrumb %}
<ol class="breadcrumb flaskbb-breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
    <li><a href="{{ url_for('management.overview') }}">{% trans %}Management{% endtrans %}</a></li>
    <li class="active">{% trans %}Manage Users{% endtrans %}</li>
</ol>
{% endblock %}

{% block management_content %}
{% from theme('macros.html') import render_pagination, group_field, navlink with context %}

<div class="col-md-3 settings-col">
    <div class="nav-sidebar">
        <ul class="nav">
            {{ navlink('management.users', _("Manage Users")) }}
            {{ navlink('management.banned_users', _('Banned Users')) }}

            {% if current_user|is_admin %}
                {{ navlink('management.add_user', _("Add User")) }}
            {% endif %}
        </ul>
    </div>
</div><!--/.col-md-3 -->

<div class="col-md-9 settings-col with-left-border">
    <div class="panel settings-panel">
        <div class="panel-heading settings-head">

            <span class="fa fa-user-times"></span> {% trans %}Banned Users{% endtrans %}

            <div class="pull-right action-buttons">
                <div class="btn-group pull-right">
                    <button type="button" class="btn btn-default btn-xs" onclick="return show_management_search()">
                        <span class="fa fa-search"></span> {% trans %}Search{% endtrans %}
                    </button>
                </div>
            </div>

        </div>
        <div class="panel-body settings-body">

            <div class="settings-search">
                <form class="search-form" role="form" method="post">
                    {{ search_form.hidden_tag() }}
                    <div class="input-group">
                        {{ group_field(search_form.search_query, css_class="form-control") }}
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button"><span class="fa fa-search"></span></button>
                        </span>
                    </div>
                </form>
            </div>

            <div class="settings-content">
                <div class="settings-meta row">
                    <div class="col-md-1 col-sm-1 col-xs-1 meta-item"><input type="checkbox" name="rowtoggle" class="action-checkall" title="Select All"/></div>
                    <div class="col-md-2 col-sm-2 col-xs-3 meta-item">{% trans %}Username{% endtrans %}</div>
                    <div class="col-md-2 col-sm-2 col-xs-3 meta-item">{% trans %}Posts{% endtrans %}</div>
                    <div class="col-md-3 col-sm-3 hidden-xs meta-item">{% trans %}Date registered{% endtrans %}</div>
                    <div class="col-md-2 col-sm-2 col-xs-3 meta-item">{% trans %}Group{% endtrans %}</div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                    {% if current_user|can_ban_user %}
                        <div class="btn-group">
                            <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                                <span class="fa fa-fw fa-cog"></span> {% trans %}Actions{% endtrans %}
                            </button>
                            <ul class="dropdown-menu slidedown">
                                <li>
                                    <button class="btn btn-link" onclick="return bulk_actions.execute('{{ url_for('management.unban_user') }}')">
                                        <span class="fa fa-fw fa-flag text-success"></span> {% trans %}Unban selected Users{% endtrans %}
                                    </button>
                                </li>
                            </ul>
                        </div>
                    {% endif %}
                    </div>
                </div>
            {% for user in users.items %}
                <div class="row settings-row hover clearfix">
                    <div class="col-md-1 col-sm-1 col-xs-1"><input type="checkbox" name="rowid" class="action-checkbox" value="{{ user.id }}" title="Select User"/></div>
                    <div class="col-md-2 col-sm-2 col-xs-3"><a href="{{ user.url }}">{{ user.username }}</a></div>
                    <div class="col-md-2 col-sm-2 col-xs-3">{{ user.post_count }}</div>
                    <div class="col-md-3 col-sm-3 hidden-xs">{{ user.date_joined|format_date('%b %d %Y') }}</div>
                    <div class="col-md-2 col-sm-2 col-xs-3">{{ user.primary_group.name }}</div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                    {% if current_user|can_ban_user and user.permissions['banned'] %}
                        <form class="inline-form" id="unban-{{user.id}}" method="post" action="{{ url_for('management.unban_user', user_id = user.id) }}">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />

                            <button class="btn btn-icon" name="confirmDialog" data-toggle="tooltip" data-placement="top" title="{% trans %}Unban{% endtrans %}">
                                <span class="fa fa-flag text-success"></span>
                            </button>
                        </form>
                    {% endif %}
                    </div>
                </div>
            {% else %}
                <div class="row settings-row clearfix">
                    <div class="col-md-12 col-sm-12 col-xs-12">{% trans %}No users found matching your search criteria.{% endtrans %}</div>
                </div>
            {% endfor %}

            </div> <!-- end settings content -->
        </div>
        <div class="panel-footer settings-footer">
            {{ render_pagination(users, url_for('management.users')) }}
        </div>
    </div>
</div>
{% include theme('confirm_dialog.html') %}
{% endblock %}

{% block scripts %}
    <script>
    var bulk_actions = new BulkActions();
    </script>
{% endblock %}
