<!-- Created by Navaneeth S, navisk13@gmail.com -->

{% extends 'base/base.html' %}
{% load static %}
{% block title %} Documents {% endblock %}

{% block body %}
    {% include 'base/nav-bar.html' %}
    <div id="wrap">
        <div id="main">
            <!-- content goes here -->
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <h1><i class="fa fa-file-text"></i> Documents</h1>

                        <div class="row">
                            <div class="card-columns">
                                {% for object in object_list %}
                                    <div class="card">
                                        <div class="card-block">
                                            <a style="color: black;" href="/static/media/{{ object.document }}">
                                                <h3 class="card-title">{{ object.title }}</h3>
                                            </a>
                                            <p class="card-text">{{ object.description }}</p>
                                            <a class="btn btn-primary add-btn"
                                               href="{% url 'document_update' object.id %}">Update
                                            </a>
                                            <a class="btn btn-danger"
                                               href="{% url 'document_delete' object.id %}">Delete
                                            </a>
                                            <p class="card-text">
                                                <small class="text-muted">{{ object.user.first_name }} {{ object.user.last_name }}</small>
                                            </p>
                                        </div>
                                    </div>
                                {% endfor %}
                            </div>
                        {% if request.user.is_authenticated %}
                            <div class="col-md-12">
                                <div class="container">
                                    <a href="{% url 'document_create' %}">
                                        <button class="btn btn-secondary">Add new</button>
                                    </a>
                                </div>
                            </div>
                        {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

    {% include 'base/footer.html' %}

    <style>
        .card {
            margin: 10px;
        }

        .container {
            margin-top: 50px;
        }
    </style>
{% endblock %}
