{% extends 'main/header.html' %}

{% block content %}
	<h2>Booklist</h2>
	<p>
		<a href="{% url 'chemie-book-upload' %}" class="btn btn-primary">Upload books</a>
	</p>
	<table class="table">
		<thead>
			<tr>
				<th>Title</th>
				<th>Author</th>
				<th>Download</th>
				<th>Delete</th>
			</tr>
		</thead>
		<tbody>
			{% for book in books %}
				<tr>
					<td>{{ book.title }}</td>
					<td>{{ book.author }}</td>
					<td>
						<a href="{{ book.pdf.url }}" class="btn btn-primary btn-small" target="_blank">
						Download pdf</a>
					</td>
					<td> 
						<form method="post" action="{% url 'chemie-book-delete' book.pk %}">
							{% csrf_token %}
							<button type="submit" class="btn btn-danger btn-small red darken-1">Delete</button>
						</form>
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}