{% extends "admin/base_site.html" %}
{% load static %}
{% load i18n %}
{% load mini_buildd_tags %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" />{% endblock %}

{% block coltype %}colMS{% endblock %}

{% block bodyclass %}dashboard{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block content %}
	<div id="mbd-django-admin-daemon-status">
		<p>
			{% if "dummy"|mbd_daemon_is_running %}
				<span class="warning">Warning:</span>
				The daemon is <span style="font-weight: bold">running</span>!&nbsp;
				It's recommended to {% mbd_api "stop" %} for extensive maintenance.
			{% else %}
				The daemon is <span style="font-weight: bold">stopped</span>!&nbsp;
				 {% mbd_api "stop" name="Restart it" %} when done.
			{% endif %}
		</p>
	</div>

	<div id="content-main">

		{% mbd_api "autosetup" %}

		{% if app_list %}
			{% for app in app_list %}
				{% if app.name == "Mini_Buildd" %}
					<div class="module">
						<table>
							<caption class="mb"><a href="{{ app.app_url }}" class="section">{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</a></caption>

							<!-- DAEMON -->
							{% include "includes/mbd_admin_index_table_header.html" with title="Daemon" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Daemon" model_path="daemon.Daemon" hide_add=True %}

							<!-- SOURCES -->
							{% include "includes/mbd_admin_index_table_header.html" with title="Sources" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Archives" model_path="source.Archive" hide_add=False wiz0_function="add_local" wiz0_name="Local" wiz0_title="Scan your local system's apt setup and add all new archives found" wiz1_function="add_debian" wiz1_name="Debian" wiz1_title="Add generic internet Debian archives" wiz2_function="add_ubuntu" wiz2_name="Ubuntu" wiz2_title="Add generic internet Ubuntu archives" %}

							{% include "includes/mbd_admin_index_table_row.html" with model_name="Sources" model_path="source.Source" hide_add=False wiz0_function="add_debian" wiz0_name="Debian" wiz0_title="Add well-known Debian sources" wiz1_function="add_ubuntu" wiz1_name="Ubuntu" wiz1_title="Add well-known Ubuntu sources" %}

							{% include "includes/mbd_admin_index_table_row.html" with model_name="Priority sources" model_path="source.PrioritySource" hide_add=False wiz0_function="add_extras" wiz0_name="Extras" wiz0_title="Add all non-base sources with default priority 1" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Apt keys" model_path="gnupg.AptKey" %}

							<!-- REPOSITORIES -->
							{% include "includes/mbd_admin_index_table_header.html" with title="Repositories" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Layouts" model_path="repository.Layout" hide_add=False wiz0_function="create_defaults" wiz0_name="Defaults" wiz0_title="Create default layout and suites" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Distributions" model_path="repository.Distribution" hide_add=False wiz0_function="add_base_sources" wiz0_name="Defaults" wiz0_title="Create default distributions for all active base sources with the host architectures" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Repositories" model_path="repository.Repository" hide_add=False wiz0_function="add_test" wiz0_name="Test" wiz0_title="Add sandbox repository 'test'" wiz1_function="add_debdev" wiz1_name="Debdev" wiz1_title="Add Debian Developer sandbox repository 'debdev'" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Uploaders" model_path="gnupg.Uploader" hide_add="True" %}

							<!-- CHROOTS -->
							{% include "includes/mbd_admin_index_table_header.html" with title="Chroots" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Dir chroots" model_path="chroot.DirChroot" hide_add=False wiz0_function="add_base_sources" wiz0_name="Defaults" wiz0_title="Add default chroots for all active base sources and host architectures" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="File chroots" model_path="chroot.FileChroot" hide_add=False wiz0_function="add_base_sources" wiz0_name="Defaults" wiz0_title="Add default chroots for all active base sources and host architectures" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Lvm chroots" model_path="chroot.LVMChroot" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Loop lvm chroots" model_path="chroot.LoopLVMChroot" hide_add=False wiz0_function="add_base_sources" wiz0_name="Defaults" wiz0_title="Add default chroots for all active base sources and host architectures" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Btrfs snapshot chroots" model_path="chroot.BtrfsSnapshotChroot" hide_add=False wiz0_function="add_base_sources" wiz0_name="Defaults" wiz0_title="Add default chroots for all active base sources and host architectures" %}

							<!-- REMOTES -->
							{% include "includes/mbd_admin_index_table_header.html" with title="Remotes" %}
							{% include "includes/mbd_admin_index_table_row.html" with model_name="Remotes" model_path="gnupg.Remote" hide_add=False %}
						</table>
					</div>
				{% endif %}
			{% endfor %}

			{% for app in app_list %}
				{% if app.name != "Mini_Buildd" %}
					<div class="module">
						<table>
							<caption class="mb"><a href="{{ app.app_url }}" class="section">{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</a></caption>
							{% for model in app.models %}
								<tr>
									{% if model.perms.change %}
										<th class="overview" scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
									{% else %}
										<th class="overview" scope="row">{{ model.name }}</th>
									{% endif %}
									{% if model.perms.add %}
										<td><a href="{{ model.admin_url }}add/" class="addlink">{% trans 'Add' %}</a></td>
									{% else %}
										<td>&nbsp;</td>
									{% endif %}
									{% if model.perms.change %}
										<td><a href="{{ model.admin_url }}" class="changelink">{% trans 'Change' %}</a></td>
									{% else %}
										<td>&nbsp;</td>
									{% endif %}
								</tr>
							{% endfor %}
						</table>
					</div>
				{% endif %}
			{% endfor %}
		{% else %}
			<p>{% trans "You don't have permission to edit anything." %}</p>
		{% endif %}
	</div>
{% endblock %}

{% block sidebar %}
	<div id="content-related">
		<div class="module" id="recent-actions-module">
			<h2>{% trans 'Recent Actions' %}</h2>
			<h3>{% trans 'My Actions' %}</h3>
			{% load log %}
			{% get_admin_log 10 as admin_log for_user user %}
			{% if not admin_log %}
				<p>{% trans 'None available' %}</p>
			{% else %}
				<ul class="actionlist">
					{% for entry in admin_log %}
						<li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
							{% if entry.is_deletion or not entry.get_admin_url %}
								{{ entry.object_repr }}
							{% else %}
								<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
							{% endif %}
							<br />
							{% if entry.content_type %}
								<span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>
							{% else %}
								<span class="mini quiet">{% trans 'Unknown content' %}</span>
							{% endif %}
						</li>
					{% endfor %}
				</ul>
			{% endif %}
		</div>
	</div>
{% endblock %}
