{% extends 'templates/app.twig' %}

	{% block content %}
<div class="row">
	<div class="col-md-10">
		<div id="booklist">
			<div class="panel">
                <div class="panel-heading">
                    <div class="text-center">
                        <div class="row">
                            <div class="col-sm-9">
                                <h3 class="pull-left">{{ book.title }}
                                    <small class="pull-left "> <a class="btn" href="{{ path_for('users.view', {'id': book.user.id }) }}">
        {{  book.user.first_name }} {{  book.user.last_name }} </a> </small>
                                </h3>
                            </div>
                            <div class="col-sm-3">
                                <h4 class="pull-right">
                                <small> {{ book.created_at }} </small>
                                </h4>
                            </div>
                        </div>
                    </div>
                </div>
                
            <div class="panel-body">
                {{ book.body }} 
            </div>
            
            <!-- <div class="panel-footer">
                <span class="label label-default">Welcome</span> <span class="label label-default">Updates</span> <span class="label label-default">July</span>
            </div> -->
        </div>
        
       </div>
    </div>
    <!-- Only the owner of this book and the admin can edit and delete it -->
     {% if (book.user_id == auth.user.id) or (auth.user.role_id <= 3) %}
		<div class="text-center">
            <p><a href="{{ path_for('books.edit', {'id': book.id } ) }}" class="btn btn-primary">Edit book</a>
                </p>
                <p> <a onclick="return confirm('Are you sure you wish to delete this Book?');"  href="{{ path_for('books.delete', {'id': book.id } ) }}" class="btn btn-warning">Delete book</a>
        
                </p>
          </div>
             
    {% endif %}
    </div>
        <div class="col-md-1"></div>
        <div class="col-md-3">
        </div>
        <div class="col-md-1">
        </div>
    </div>
{% endblock %}
