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

	{% block content %}
<div class="row">
	<div class="col-md-10">
		<div id="postlist">
			<div class="panel">
                <div class="panel-heading">
                    <div class="text-center">
                        <div class="row">
                            <div class="col-sm-9">
                                <h3 class="pull-left">{{ post.title }}
                                    <small class="pull-left "> <a class="btn" href="{{ path_for('users.view', {'id': post.user.id }) }}">
        {{  post.user.first_name }} {{  post.user.last_name }} </a> </small>
                                </h3>
                            </div>
                            <div class="col-sm-3">
                                <h4 class="pull-right">
                                <small> {{ post.created_at }} </small>
                                </h4>
                            </div>
                        </div>
                    </div>
                </div>
                
            <div class="panel-body">
                {{ post.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 post and the admin can edit and delete it -->
     {% if (post.user_id == auth.user.id) or (auth.user.role_id <= 3) %}
		<div class="text-center">
            <p><a href="{{ path_for('posts.edit', {'id': post.id } ) }}" class="btn btn-primary">Edit post</a>
                </p>
                <p> <a onclick="return confirm('Are you sure you wish to delete this Post?');"  href="{{ path_for('posts.delete', {'id': post.id } ) }}" class="btn btn-warning">Delete post</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 %}
