{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}User Profile{% endblock %}{% endblock %}

{% block content %}
	<section>
		<h2>Package (EMail) Notifications</h2>

		{% mbd_token as table_id %}
		<div id="mbd-package-notifications-table_wrapper">
			<table id="{{ table_id }}" style="width: 100%">
				{% 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>
		</div>
	</section>

	<section>
		<h2>Package uploads</h2>
		<p>
			Status: <code class="mbd-model-status-{{ user.uploader.get_status_display }}">{{ user.uploader|default:"ERROR: User has no uploader config. Please contact administrator." }}</code>
		</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 %}
