{% extends "admin/change_form.html" %}
{% load i18n %}

{% block extrahead %}
{{block.super}}
{% include "js/jquery.html" %}
{% include "js/jquery-ui.html" %}
<script type="text/javascript" src="{{MEDIA_URL}}djblets/js/jquery.gravy.js?{{MEDIA_SERIAL}}"></script>
<script type="text/javascript" src="{{MEDIA_URL}}rb/js/repositoryform.js?{{MEDIA_SERIAL}}"></script>

<script type="text/javascript">
{% with adminform.form as form %}
{%  include "admin/repository_fields.js" %}
{% endwith %}
</script>
{% endblock %}

{% block object-tools-items %}
{% if adminform.form.public_key %}
 <li><a href="#" id="show-ssh-key-link">{% trans "Show SSH Public Key" %}</a></li>
{% endif %}
{{block.super}}
{% endblock %}

{% block form_top %}
{%  with adminform.form as form %}
{%   include "admin/repository_confirmations.html" %}
{%  endwith %}

{%  if adminform.form.errors and adminform.form.hosting_account_linked %}
<div class="confirmation">
 <p><b>{% trans "Account successfully linked." %}</b></p>
 <p>{% blocktrans %}
  Your hosting account was successfully linked. You will not need to
  link it again when fixing the remaining errors.
 {% endblocktrans %}</p>
</div>
{%  endif %}

{%  if adminform.form.public_key %}
<p>
 <b>{% trans "Note:" %}</b>
{% blocktrans %}
 If your provider or repository requires an SSH key for access, you can click
 "Show SSH Public Key" to the right.
{% endblocktrans %}
</p>
{%  endif %}
{% endblock %}

{% block field_sets %}
{%  for fieldset in adminform %}
<fieldset class="module aligned {{fieldset.classes}}">
{%   if fieldset.name %}<h2>{{fieldset.name}}</h2>{% endif %}
{%   if fieldset.description %}
 <div class="description">{{fieldset.description|safe}}</div>
{%   endif %}

{%   for line in fieldset %}
{%    for adminfield in line %}
{%     with adminfield.field as field %}
{%      include "siteconfig/settings_field.html" %}
{%     endwith %}
{%    endfor %}
{%   endfor %}

{%   if fieldset.name == adminform.form.REPOSITORY_INFO_FIELDSET %}
{%    for hosting_service, repo_types in adminform.form.repository_forms.items %}
{%     for repo_type_id, repo_form in repo_types.items %}
  <div class="repo-form" id="repo-form-{{hosting_service}}{% if repo_type_id %}-{{repo_type_id}}{% endif %}" style="display: none;">
{%      for field in repo_form %}
{%       include "siteconfig/settings_field.html" %}
{%      endfor %}
  </div>
{%     endfor %}
{%    endfor %}
{%   else %}
{%    if fieldset.name == adminform.form.BUG_TRACKER_FIELDSET %}
{%     for hosting_service, bug_tracker_types in adminform.form.bug_tracker_forms.items %}
{%      for bug_tracker_type_id, bug_tracker_form in bug_tracker_types.items %}
  <div class="bug-tracker-form" id="bug-tracker-form-{{hosting_service}}{% if bug_tracker_type_id %}-{{bug_tracker_type_id}}{% endif %}" style="display: none;">
{%       for field in bug_tracker_form %}
{%        include "siteconfig/settings_field.html" %}
{%       endfor %}
  </div>
{%      endfor %}
{%     endfor %}
{%    endif %}
{%   endif %}
</fieldset>
{%  endfor %}
{% endblock %}
