{% extends "main_django.html" %}
{% load i18n configuration %}

{% block title %}
  {% trans "Authorize" %} | {% platform_name %}
{% endblock %}

{% block body %}
    <main id="main" aria-label="Content" tabindex="-1">
      <section class="container authorize {{ selected_tab }}" id="authorize-content">
        <div class="wrapper-authorize">
            <div class="block-center">
                {% if not error %}
                    <form id="authorizationForm" method="post">
                        <h1 class="block-center-heading">{% trans "Authorize" %} {{ application.name }}?</h1>
                        {% csrf_token %}

                        {% for field in form %}
                            {% if field.is_hidden %}
                                {{ field }}
                            {% endif %}
                        {% endfor %}

                        <p>{% trans "The above application requests the following permissions from your account:" %}</p>
                        <ul>
                            {% for scope in scopes_descriptions %}
                                <li>{{ scope }}</li>
                            {% endfor %}
                        </ul>
                        <p>{% trans "Please click the 'Allow' button to grant these permissions to the above application. Otherwise, to withhold these permissions, please click the 'Cancel' button." %}
                        </p>

                        {{ form.errors }}
                        {{ form.non_field_errors }}

                        <div class="control-group">
                            <div class="controls">
                                <button type="submit" class="btn btn-authorization-cancel" name="cancel"/>{% trans "Cancel" %}</button><button type="submit" class="btn btn-authorization-allow" name="allow" value="Authorize"/>{% trans "Allow" %}</button>
                            </div>
                        </div>
                    </form>

                {% else %}
                    <h2>{% trans "Error" %}: {{ error.error }}</h2>
                    <p>{{ error.description }}</p>
                {% endif %}
            </div>
        </div>
      </section>
    </main>
{% endblock %}
