{% extends "base.html" %}

{% comment %}
# This file is part of k4ever, a point-of-sale system
#   Contact............  <k4ever@lists.someserver.de>
#   Website............  http://k4ever.someserver.de/
#   Bug tracker........  http://k4ever.someserver.de/report
#
# Licensed under GNU Affero General Public License v3 or later
{% endcomment %}

{% block "content" %}
	<ul id="tab" class="nav nav-tabs">
		<li class="active"><a href="#plugins" data-toggle="tab">Pluginberechtigungen</a></li>
		<li><a href="#account" data-toggle="tab">Konto</a></li>
	</ul>

	<div class="tab-content">
		<div id="plugins" class="tab-pane active">
			<h2>Pluginberechtigungen</h2>
			{% if pluginerror %}
				<div class="alert alert-error">
					<h4 class="alert-heading">{{ pluginerror|safe }}</h4>
				</div>
			{% endif %}

			<table class="table table-striped">
				<thead>
					<tr>
						<th>Authorisiert</th>
						<th>Name</th>
						<th>Autor_in</th>
						<th>Beschreibung</th>
						<th>AuthBlob</th>
						<th>Erlauben/Verbieten</th>
					</tr>
				</thead>
				<tbody>
					{% for p in permissions %}
						<tr>
							<td style="text-align: center"><i class="icon-ok "></i></td>
							<td>{{ p.plugin.name }}<br/>{{ p.plugin.version }}</td>
							<td>{{ p.plugin.author }}</td>
							<td>{{ p.plugin.descr }}</td>
							<td>
								{% if p.plugin.userCanWriteAuthblob %}
									<form method="post" action="/user/settings/plugin/authblob/{{ p.plugin.id }}/">
										{% csrf_token %}
										<textarea name="authblob">{{ p.authblob }}</textarea>
										<input type="submit" class="btn" value="Speichern">
									</form>
								{% else %}
									{% if p.plugin.userCanReadAuthblob %}
										{{ p.authblob }}
									{% else %}
										---
									{% endif %}
								{% endif %}
							</td>
							<td><a href="/user/settings/plugin/deny/{{ p.plugin.id }}/" class="btn btn-danger">Plugin verbieten</a></td>
						</tr>
					{% endfor %}
					{% if unallowed %}
						{% for plugin in unallowed %}
							<tr>
								<td></td>
								<td>{{ plugin.name }}<br/>{{ plugin.version }}</td>
								<td>{{ plugin.author }}</td>
								<td>{{ plugin.descr }}</td>
								<td></td>
								<td><a class="btn btn-success" href="/user/settings/plugin/allow/{{ plugin.id }}/">Plugin erlauben</a></td>
							</tr>
						{% endfor %}
					{% endif %}
				</tbody>
			</table>
		</div>

		<div class="tab-pane" id="account">
			<h2>Passwort</h2>
			{% if form %}
				{% if password_success %}
					<div class="alert alert-success">
						<h4 class="alert-heading">Passwort geändert.</h4>
					</div>
				{% endif %}

				<form method="post" action="#" class="form-horizontal">
					{% csrf_token %}
					{% include "form.html" with form=form %}

					<div class="control-group">
						<div class="controls">
							<input class="btn btn-primary" type="submit" value="Passwort ändern" />
						</div>
					</div>
				</form>
			{% else %}
				<p>Da du dich nicht direkt über das Kassensystem authentifizierst (sondern z.B. über LDAP) kannst du dein Passwort hier nicht ändern.</p>
			{% endif %}
		</div>
	</div>
{% endblock %}
