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

{% block scripts %}
{{block.super}}
{% compressed_js "repositoryform" %}

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

{% block object-tools %}
<ul class="object-tools">
{%  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 %}
{%   if change and not is_popup %}
 <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
{%    if has_absolute_url %}
 <li><a href="../../../r/{{content_type_id}}/{{object_id}}/" class="viewsitelink">{% trans "View on site" %}</a></li>
{%    endif %}
{%   endif %}
</ul>
{%  endblock %}
{% 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 %}
