{% extends "base.html" %}

{% load handletags %}

{% block content %}
<div class="row">
	<div class="col-sm-12">
		<div class="panel panel-default">
			<div class="panel-heading">Resource Requests</div>
			<div class="panel-body">
				{% if not mnts.count %}
					<div class="alert alert-danger" role="alert">
						<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
						<strong>Warning</strong>: You have no maintainer object. Create one <a class="alert-link" href="{% url "whoisdb:dashboard" %}">here</a> before starting resource requests.
					</div>
				{% endif %}
				<p>
				<a href="{% url "rrequests:create" %}">Start a new request for resources</a>
				</p>

				<p>
				Current and old resource requests:
				</p>

				<p>
				<table class="table">
					<tr>
						<th>Applicant</th>
						<th>Provider</th>
						<th>Status</th>
						<th>Subject</th>
						<th>Created at</th>
						<th>Last Modified</th>
						<th>Resources</th>
						<th></th>
					</tr>
					{% for request in requests %}
						<tr>
							<td>{{ request.applicant|linkObject }}</td>
							<td>{{ request.provider|linkObject }}</td>
							<td>{{ request.get_status_display }}</td>
							<td><a href="{% url "rrequests:show" request.pk %}">{{ request.subject }}</a></td>
							<td>{{ request.created }}</td>
							<td>{{ request.lastAction }}</td>
							<td>{{ request.grantedResources|default:"-" }}</td>
							<td><a href="{% url "rrequests:show" request.pk %}">View</a></td>
						</tr>
					{% endfor %}
				</table>
				</p>


			</div>
		</div>
	</div>
</div>
{% endblock %}