## mako
<%page expression_filter="h"/>
<%inherit file="../main.html"/>
<%!
from django.utils.translation import ugettext as _

from openedx.core.djangoapps.api_admin.models import ApiAccessRequest
from openedx.core.djangolib.markup import HTML, Text
%>

<%block name="pagetitle">
${_("API Access Request Status")}
</%block>

<div id="api-access-wrapper">
  <h1 id="api-header">${_("{platform_name} API Access Request").format(platform_name=settings.PLATFORM_NAME)}</h1>
  <div class="request-status request-${status}">
    <p id="api-access-status">
      % if status == ApiAccessRequest.PENDING:
      ## Translators: "platform_name" is the name of this Open edX installation.
      ${Text(_('Your request to access the {platform_name} Course Catalog API is being processed. You will receive a message at the email address in your profile when processing is complete. You can also return to this page to see the status of your API access request.')).format(
        platform_name=Text(settings.PLATFORM_NAME)
      )}

      % elif status == ApiAccessRequest.DENIED:
      ## Translators: "platform_name" is the name of this Open edX installation. "api_support_email_link" is HTML for a link to email the API support staff.
      ${Text(_('Your request to access the {platform_name} Course Catalog API has been denied. If you think this is an error, or for other questions about using this API, contact {api_support_email_link}.')).format(
        platform_name=Text(settings.PLATFORM_NAME),
        api_support_email_link=HTML('<a href="mailto:{email}">{email}</a>').format(email=Text(api_support_email))
      )}

      % elif status == ApiAccessRequest.APPROVED:
      ${Text(_('Your request to access the {platform_name} Course Catalog API has been approved.')).format(
        platform_name=Text(settings.PLATFORM_NAME)
      )}

      % if application:
      <div class="application-info">
        <p><span class="application-label">${_("Application Name") + ":"}</span> ${application.name}</p>
        <p><span class="application-label">${_("API Client ID") + ":"}</span> ${application.client_id}</p>
        <p><span class="application-label">${_("API Client Secret") + ":"}</span> ${application.client_secret}</p>
        <p><span class="application-label">${_("Redirect URLs") + ":"}</span> ${application.redirect_uris}</p>
      </div>

      <p>${_('If you would like to regenerate your API client information, please use the form below.')}</p>
      
      % endif
      <div class="catalog-body">
        <div class="api-form-container">
          <form id="api-form-fields" method="post" class="api-form">
            <input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
            ${form.as_p() | n, decode.utf8}
            <input id="api-access-submit" type="submit" value="${_('Generate API client credentials')}"/>
          </form>
        </div>
      </div>
      % endif
    </p>

    <p>
      ## Translators: "platform_name" is the name of this Open edX installation. "link_start" and "link_end" are the HTML for a link to the API documentation. "api_support_email_link" is HTML for a link to email the API support staff.
      ${Text(_('To learn more about the {platform_name} Course Catalog API, visit {link_start}our API documentation page{link_end}. For questions about using this API, contact {api_support_email_link}.')).format(
        platform_name=Text(settings.PLATFORM_NAME),
        link_start=HTML('<a href="{}">').format(Text(api_support_link)),
        link_end=HTML('</a>'),
        api_support_email_link=HTML('<a href="mailto:{email}">{email}</a>').format(email=Text(api_support_email))
      )}
    </p>
  </div>
</div>
