{% extends "mini_buildd/base.html" %}

{% block content %}
	<header>
		<h1>{% block title %}User Profile{% endblock %}</h1>
		<nav></nav>
	</header>

	<section>
		<h2>Package (EMail) Notifications</h2>

		{% mbd_token as table_id %}
		<table id="{{ table_id }}">
			{% mbd_datatable table_id order='[0, "desc"]' columns='[null, null, {"searchable": false, "orderable": false}, {"searchable": false, "orderable": false}]'%}
			<thead>
				<tr>
					<th>Source</th>
					<th>Distribution</th>
					<th>Description</th>
					<th>Actions</th>
				</tr>
			</thead>
			<tbody>
				{% for s in view.mbd_subscriptions %}
					<tr>
						<td>{{ s.package }}</td>
						<td>{{ s.distribution }}</td>
						<td>{{ s }}</td>
						<td>{% mbd_api "unsubscribe" value_source=s.package value_distribution=s.distribution hide_options=True %}</td>
					</tr>
				{% endfor %}
			</tbody>
			<tfoot>
				<tr>
					<th colspan="4">{% mbd_api "subscribe" %}</th>
				</tr>
			</tfoot>
		</table>
	</section>

	<section>
		<h2>Package uploads</h2>
		<p>
			Status: <kbd class="{% mbd_cssmap 'model_status' user.uploader.get_status_display %}">{{ user.uploader|default:"ERROR: User has no uploader config. Please contact administrator." }}</kbd>
		</p>

		<p>
			<em>Note:</em> Setting a new key will <em>automatically
				deactivate your uploader profile</em>; an administrator
				needs to (verify your key and) manually re-activate you
				later.
		</p>
		{% mbd_api "set_user_key" value_key=user.uploader.key %}
	</section>
{% endblock %}
