{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}{{ route|title }}{% endblock %}{% endblock %}
{% block tooltip %}{{ view.mbd_repositories|length }} repositories{% endblock %}
{% block menu %}
	<li>{% mbd_api "keyring_packages" %}</li>
	<li>{% mbd_api "test_packages" %}</li>
	<li><a class="mbd-icon" href="{% url 'admin:mini_buildd_repository_changelist' %}"><img class="mbd-icon" src="{% static 'icons/configure.svg' %}" alt="Configure"></a></li>
{% endblock %}

{% block content %}
	{% for r in view.mbd_repositories %}
		<section>
			<header class="mbd-grid-lcr">
				<h2>{{ r }}</h2>
				<nav>
				</nav>
				<nav>
					<ul>
						{% if r.external_home_url %}
							<li><a class="mbd-icon" href="{{ r.external_home_url }}" title="External doc for this repository"><img class="mbd-icon" src="{% static 'icons/manual.svg' %}" alt="Manual"></a></li>
						{% endif %}
						<li>{% mbd_api "reindex" value_repositories=r.identity %}</li>
						<li>{% mbd_api "sources_list" value_repositories=r.identity %}</li>
						<li>{% mbd_api "uploaders" value_repositories=r.identity %}</li>
						<li><a class="mbd-icon" href="{% url 'admin:mini_buildd_repository_change' r.identity %}"><img class="mbd-icon" src="{% static 'icons/configure.svg' %}" alt="Configure"></a></li>
					</ul>
				</nav>
			</header>

			{% mbd_token as table_id %}
			<table id="{{ table_id }}" style="width: 100%;">
				{% mbd_datatable table_id %}
				<thead>
					<tr>
						<th>Distribution</th>
						<th>Menu</th>
					</tr>
				</thead>
				<tbody>
					{% for d in r.distributions.all|mbd_sorted %}
						<tr>
							<td><a href="{% url 'repositories' r.identity|add:'/dists/'|add:d.base_source.codename|add:'-'|add:r.identity|add:'-'|add:r.layout.suiteoption_set.all.first.suite.name %}"><span class="mbd-table-distribution">{{ d }}</span></a></td>
							<td>{% mbd_api "sources_list" value_repositories=r.identity value_codenames=d.base_source.codename %}</td>
						</tr>
					{% endfor %}
				</tbody>
			</table>
		</section>
	{% endfor %}
{% endblock %}
