{% extends 'base.html' %}
{% load static %}

{% block content %}
<article class="panel">
    <header>
        <h1 class="greeting"><em>Welcome {{profile.user.first_name}} {{profile.user.last_name }}</em>
            <br>
            Here's what's going on today
        </h1>
    </header>
    <section>
        <h3 class="domain__heading">Birthdays</h3>
        <ul>
        {% for student in birthdays %}
            <li><strong><a href="{% url 'student-detail' student.pk %}">{{student}}</a></strong> is turning {{student.age|add:1}} on {{student.dob|date:"M j"}}</li>
        {% empty %}
        <p>No Birthdays this next week.</p>
        {% endfor %}
        </ul>
    </section>
    <section>
        <h3 class="domain__heading">Today's Assignments</h3>
        <ul>
        {% for component in components %}
            <li>
                {{component.subject}}, <a href="{% url 'component-detail' component.subject.pk component.pk %}">{{component}}</a>
            </li>
        {% empty %}
        <p>Nothing for today.</p>
        {% endfor %}
        </ul>
    </section>
    <section>
        <h3 class="domain__heading">Today's Attendance</h3>
        {% for day in attendance %}
            <p><strong><a href="{% url 'day-update' day.pk %}">{{day.date}}</a></strong></p>
            <table>
                <thead>
                    <tr>
                        <td>Student</td>
                        <td colspan="2">Status</td>
                    </tr>
                </thead>
                <tbody>
                    {% for entry in day.entry_set.all %}
                    <tr>
                        <td>{{entry.student}}</td>
                        <td>{{entry.get_status_display}}</td>
                        <td><a href="{% url 'entry-update' entry.pk %}">Update</a></td>
                    </tr>                    
                    {% endfor %}
                </tbody>
            </table>
        {% empty %}
            <p class="greeting">No attendance taken yet: <a href="{% url 'day-create' %}" class="action-button">Take attendance</a></p>
        {% endfor %}
    </section>
    <section>
        <h3 class="domain__heading">Assignments to be graded</h3>
        <ul>
        {% for component in ungraded_components %}
            <li>
                {{component.subject}}, <a href="{% url 'component-detail' component.subject.pk component.pk %}">{{component}}</a>
            </li>
        {% empty %}
        <p>Everything is graded to far.</p>
        {% endfor %}
        </ul>
    </section>
</article>
{% endblock %}
