{% extends 'base.html' %}

{% block title %}
Index
{% endblock %}

{% block content %}
<h1>Index der Applikation</h1>
    <form action="/posts" method="POST">


    {% for notice in notices %}
    <div>
        <p>published: {{ notice.pub_start }}</p>
        <h2><a href="">{{ notice.notice_title }}</a></h2>
        <p>{{ notice.notice_text|linebreaksbr }}</p>
        <p>
            <a href="{% url 'delete' deleteId=notice.id %}" class="btn btn-danger">
                Meldung löschen
            </a>
        </p>
    </div>
    {% endfor %}

        <div>
            <p>
                <a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a>
            </p>
        </div>

    <script>
        var es = new ReconnectingEventSource('/events/');
        es.addEventListener('message', function (e) {console.log(e.data);location.reload();}, false);
    </script>

</form>
{% endblock %}



