{% extends "base_nav.html" %}
{% load humanize %}
{% load i18n %}
{% load staticfiles %}
{% block "title" %}{% trans "Review Access Request" %}{% endblock %}
{% block "css" %}
<link href="{% static 'css/secrets.css' %}" rel="stylesheet">
{% endblock %}
{% block "content" %}
<script type="text/javascript">
$(function () {
	$("[data-toggle='tooltip']").tooltip({container: 'body'});
});
</script>
<div class="container">
	<div class="row">
		<div class="col-md-8 col-md-offset-2">
			<h1>{% trans "Review Access Request" %}</h1>
			<br>
		</div>
	</div>
	<div class="row">
		<div class="col-md-8 col-md-offset-2">
			<div class="secret-attributes panel">
				<br>
				<table class="table-responsive">
					<tr>
						<td>{% trans "Requester" %}</td>
						<td>
							{{ access_request.requester }}
						</td>
					</tr>
					<tr>
						<td>{% trans "Secret" %}</td>
						<td>
							<a href="{{ access_request.secret.get_absolute_url }}">{{ access_request.secret.name }}</a>
						</td>
					</tr>
					<tr>
						<td>{% trans "Requested" %}</td>
						<td>
							<span data-toggle="tooltip" data-placement="top" title="{{ access_request.created|date:"Y-m-d H:i:s" }}">
								{{ access_request.created|naturalday:"Y-m-d" }}
							</span>
						</td>
					</tr>
					{% if access_request.reason_request %}
					<tr>
						<td>{% trans "Reason" %}</td>
						<td>
							{{ access_request.reason_request }}
						</td>
					</tr>
					{% endif %}
				</table>
				<br>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-8 col-md-offset-2">
			<form role="form" method="POST" action="{% url "secrets.access_request-review" hashid=access_request.hashid action="deny" %}">
				{% csrf_token %}
				<input type="text" class="form-control input-lg" name="reason" placeholder="{% trans "Reason for turning down the request (optional)" %}">
				<br>
				<button type="submit" class="btn btn-danger btn-lg pull-left">
					&nbsp; &nbsp; &nbsp; <i class="fa fa-thumbs-down"></i>&nbsp; {% trans "Deny access" %} &nbsp; &nbsp; &nbsp;
				</button>

			</form>
			<form role="form" method="POST" action="{% url "secrets.access_request-review" hashid=access_request.hashid action="allow" %}">
				{% csrf_token %}
				<button type="submit" class="btn btn-success btn-lg pull-right">
					&nbsp; &nbsp; &nbsp; <i class="fa fa-thumbs-up"></i>&nbsp; {% trans "Allow access" %} &nbsp; &nbsp; &nbsp;
				</button>
			</form>
		</div>
	</div>
</div>
{% endblock %}
