{% extends base %}
{% from 'macro.html' import breadcrumbs with context %}
{% from 'macro.html' import form_fields with context %}
{% block content %}

<div class="row">
    <div class="span12">
        {{- breadcrumbs([
            [url_for('admin_index.index'), _('Administration')],
            [url_for('admin_authors.index'), _('Authors')]
        ]) }}
        <h1>{{ page_title }}</h1>
        {% if author.id == current_user.id %}<h3>{{ _("(it's you)") }}</h3>{% endif %}

        {% if saved %}<div class="alert-mini green">{{ _('Saved!') }}</div>{% endif %}

        {% if config['DEBUG'] and current_user.is_superuser %}
            <div class="password-hash">{{ author.password }}</div><br/>
        {% endif %}

        <form class="form-horizontal" method="POST" enctype="multipart/form-data">
        <div class="control-group">
            <label class="control-label">{{ _('Registered at') }}</label>
            <div class="controls">
                <span style="display: inline-block; padding-top: 5px;">{% if author.date_joined %}<time datetime="{{ author.date_joined.strftime('%Y-%m-%dT%H:%M:%SZ') }}">
                    {{ author.date_joined|datetimeformat('d MMMM Y, HH:mm') }}
                </time>{% else %}N/A{% endif %}</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">{{ _('Last visit') }}</label>
            <div class="controls">
                <span style="display: inline-block; padding-top: 5px;">{% if author.last_visit %}<time datetime="{{ author.last_visit.strftime('%Y-%m-%dT%H:%M:%SZ') }}">
                    {{ author.last_visit|datetimeformat('d MMMM Y, HH:mm') }}
                </time>{% else %}N/A{% endif %}</span>
            </div>
        </div>
        {% if not is_system_user %}
            {{ form_fields(form) }}
            <div class="controls">
                <input type="submit" value="{{ _('Save') }}" class="btn btn-primary" />
            </div>
        {% else %}
            <div class="control-group">
                {{ _('This is system user account, you cannot edit it.') }}
            </div>
        {% endif %}
        </form>

        {% if author.is_active and author.id != current_user.id %}
        <form action="{{ url_for('admin_authors.login', pk=author.id) }}" class="form-horizontal" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
        <div class="controls">
            <input type="submit" value="{{ _('Log in as this user') }}" class="btn btn-warning" />
        </div>
        </form>
        {% endif %}

        {{- breadcrumbs([
            [url_for('admin_index.index'), _('Administration')],
            [url_for('admin_authors.index'), _('Authors')]
        ]) }}
    </div>
</div>
{% endblock %}
