{% extends "base.html" %}
{% block title %}
	{{show.name}} Discussions - Episodes.Community
{% endblock %}
{% block content %}
<div class="container mb-5 mt-5">
	<nav aria-label="breadcrumb">
		<ol class="breadcrumb">
			<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
			<li class="breadcrumb-item active" aria-current="page">Discussions</li>
		</ol>
	</nav>
	<h1>{{show.name}} Discussion Boards</h1>
	<p>Discuss {{show.name}} with your fellow community members!</p>
	<div class="d-flex flex-row-reverse mb-4">
		{% if user.is_authenticated %}
		<a href="{{show.url}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i>&nbsp;Create New Board</a>
		{% else %}
		<p><a href="/login">Log in</a> to create boards</p>
		{% endif %}
	</div>
	<div class="bg-light rounded p-2 row">
		<div class="col">Board Name</div>
		<div class="col-2">Latest Reply</div>
	</div>
	{% for board in boards %}
	<div class="board border-bottom">
		<div class="row">
			<div class="col">
				<h2><a href="{{show.url}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{% if board.locked %}<i class="fa fa-fw fa-lock"></i>{% endif %}{% if board.pinned %}<i class="fa fa-fw fa-thumb-tack"></i>{% endif %}{{board.title}}</a></h2>
				<span class="text-muted font-weight-light">Submitted {{board.timestamp}} by 
					{% if board.user.is_staff %}
						<span class="mod"><i class="fa fa-fw fa-shield"></i></span>
					{% endif %}
					<span class="display_name">{{board.user.display_name}}</span>
				</span>
			</div>
			<div class="col-2">
				{% if board.num_replies > 0 %}
				<div class="reply mt-2">
					<div class="user">
						<small class="text-muted font-weight-light">by </small>
						{{board.latest_reply.user.display_name}}
					</div>
					<small class="timestamp text-muted font-weight-light">{{board.latest_reply.timestamp}}</small>
				</div>
				{% else %}
				<span class="text-muted font-weight-light">No replies</span>
				{% endif %}
			</div>
		</div>
	</div>
	{% empty %}
	<h3>Nobody has started any discussions for this show!</h3>
	{% endfor %}

	{% if boards.has_other_pages %}
	<nav aria-label="Boards navigation">
		<ul class="pagination">
			{% if boards.has_previous %}
			<li class="page-item">
				<a href="?page={{ boards.previous_page_number }}" class="page-link">Previous</a>
			</li>
			{% else %}
			<li class="page-item disabled">
				<a class="page-link" href="#" tabindex="-1">Previous</a>
			</li>
			{% endif %}
			{% for i in boards.paginator.page_range %}
			{% if boards.number == i %}
			<li class="page-item active">
				<span class="page-link">{{ i }} <span class="sr-only">(current)</span></span>
			</li>
			{% else %}
			<li class="page-item">
				<a class="page-link" href="?page={{ i }}">{{ i }}</a>
			</li>
			{% endif %}
			{% endfor %}
			{% if boards.has_next %}
			<li class="page-item">
				<a href="?page={{ boards.next_page_number }}" class="page-link">Next</a>
			</li>
			{% else %}
			<li class="page-item disabled">
				<a class="page-link" href="#" tabindex="-1">Next</a>
			</li>
			{% endif %}
		</ul>
	</nav>
	{% endif %}
</div>
{% endblock %}