{#
# This file is part of Invenio.
# Copyright (C) 2014 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#}

{%- extends config.OAUTH2SERVER_BASE_TEMPLATE %}

{%- import "invenio_oauth2server/settings/helpers.html" as helpers with context %}

{% block page_body %}
<div class="row">
<div class="col-md-8 col-md-offset-2">
{{ helpers.panel_start(_('Authorize application'), icon='fa fa-shield fa-fw') }}
Authorize application
<h1 align="center">{{ _('Authorize application') }}</h1>
<h3 align="center">{{ _("Application '%(client_name)s' by '%(client_user)s' wants permission to access your account.",
                        client_name=client.name, client_user=client.user.nickname or client.user.email) }}</h3>
<hr />
<div class="row">
<div class="col-md-8">
  <h4>{{ _('Review permissions') }}</h4>
  {% for group in scopes|groupby('group') %}
    {% if loop.first %}<table class="table table-striped table-bordered"><tbody>{% endif %}
      <tr>
        <td><strong>{{group.grouper}}</strong></td>
        <td><ul>{% for scope in group.list %}<li>{{scope.help_text}}</li>{% endfor %}</ul></td>
      </tr>
    {% if loop.last %}</tbody></table>{% endif %}
  {% endfor %}
</div>
<div class="col-md-4">
  <div class="well">
    <span class="text-muted">{{ _('Application') }}</span>
    <h4>{{client.name}}</h4>
    {% if client.description %}<p>{{client.description}}</p>{% endif %}
    {% if client.website %}<p><a href="{{client.website}}">{{ _('Visit application website') }}</a></p>{% endif %}
  </div>
</div>
</div>
<hr />
<div align="center">
  <form action="" method="POST">
    <button type="submit" value="yes" name="confirm" class="btn btn-success"><i class="fa fa-check"></i> {{ _('Authorize application') }}</button>
    <button type="submit" value="no" name="confirm" class="btn btn-danger"><i class="fa fa-ban"></i> {{ _('Reject') }}</button>
  </form>
</div>
{{ helpers.panel_end() }}
</div>
</div>
{% endblock %}
