{% load djblets_utils i18n %}

<fieldset class="module confirmation" id="ssh-public-key-popup">
 <h2>{% trans "SSH Public Key:" %}</h2>
 <textarea cols="65" rows="10" readonly="readonly" class="public-key">{{form.public_key_str}}</textarea>
</fieldset>

{%  with form.hostkeyerror as hostkeyerror %}
{%  with form.certerror as certerror %}
{%  with form.certerror.certificate as certificate %}
{%   if hostkeyerror or certerror %}
<fieldset class="module confirmation">

{%   if hostkeyerror %}
 {{hostkeyerror|paragraphs}}
{%    if hostkeyerror.key %}
 <p>RSA key fingerprint is {{hostkeyerror.key}}.</p>
{%    endif %}
{%    if hostkeyerror.expected_key %}
 <p>Expected fingerprint is {{hostkeyerror.expected_key}}.</p>
{%    endif %}

{%   elif certerror %}

 {{certerror|paragraphs}}
{%    if certificate.failures %}
 <p>{% trans "There were errors validating this certificate:" %}</p>
 <ul>
{%     for failure in certificate.failures %}
  <li>{{failure}}</li>
{%     endfor %}
 </ul>
{%    endif %}
 <div class="cert-info">
  <h3>{% trans "Certificate information:" %}</h3>
{%    if certificate.hostname %}
  <p><label>{% trans "Hostname:" %}</label>{{certificate.hostname}}</p>
{%    endif %}
{%    if certificate.valid_from %}
  <p><label>{% trans "Valid:" %}</label>
{%     blocktrans with certificate.valid_from as valid_from and certificate.valid_until as valid_until %}
   from {{valid_from}} until {{valid_until}}
{%     endblocktrans %}
  </p>
{%    endif %}
{%    if certificate.issuer %}
  <p><label>{% trans "Issuer:" %}</label>{{certificate.issuer}}</p>
{%    endif %}
  <p><label>{% trans "Fingerprint:" %}</label> {{certificate.fingerprint}}</p>
 </div>
{%   endif %}

 <p>{% blocktrans %}
  Do you trust this host, or do you want to go back and edit the
  repository information?
 {% endblocktrans %}</p>
 <div class="form-row">
  <input type="submit" name="trust_host" value="{% trans "I trust this host" %}" />
  <input type="submit" name="reedit_repository" value="{% trans "Re-edit repository" %}" />
 </div>
</fieldset>
{%   endif %}
{%  endwith %}
{%  endwith %}
{%  endwith %}

{%  with form.userkeyerror as userkeyerror %}
{%   if userkeyerror %}
<fieldset class="module confirmation">
{{userkeyerror|paragraphs}}

{% url 'settings-ssh' as ssh_settings_url %}
<p>{% blocktrans %}
 Review Board doesn't have a public key to send to the server. You can
 <a href="{{ssh_settings_url}}" target="ssh_settings">create one</a>, add it to the server,
 and then try again.
{% endblocktrans %}</p>
</fieldset>
{%   endif %}
{%  endwith %}
