{% extends 'base.html' %}
{% block title %}{{ title }} | Learning management system{% endblock title %}

{% block content %}

<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="/">Home</a></li>
        <li class="breadcrumb-item active" aria-current="page">Allocation list</li>
    </ol>
</nav>

{% if request.user.is_superuser %}
<div class="manage-wrap">
    <a class="btn btn-primary" href="{% url 'course_allocation' %}"><i class="fas fa-plus"></i>Allocate Now</a>
</div>
{% endif %}

<div class="title-1"><i class="fas fa-tasks"></i>Course Allocations</div>
<br>
<br>

{% include 'snippets/messages.html' %}
{% include 'snippets/filter_form.html' %}

<div class="table-responsive table-shadow p-0 mt-4">
    <table class="table table-light table-striped">
        <thead>
            <tr>
                <th>#</th>
                <th>Lecturer</th>
                <th>Courses</th>
                {% if request.user.is_superuser %}
                <th>Action</th>
                {% endif %}
            </tr>
        </thead>
        {% for course in filter.qs %}
        <tbody>
            <tr>
                <td> {{ forloop.counter }}.</td>
                <td><a href="{{ course.lecturer.get_absolute_url }}">{{ course.lecturer.get_full_name }}</a></td>
                <td><div class="flex">{% for i in course.courses.all %}
                        <div class="flex"><a class="edit-btn" href="{{ i.get_absolute_url }}">{{ i }}</a></div>
                    {% endfor %}</div>
                </td>
                {% if request.user.is_superuser %}
                <td><div class="update-delete">
                    <a href="{% url 'edit_allocated_course' pk=course.pk %}" class="update" title="Edit or Update">
                        <i class="fas fa-edit"></i>
                    </a>
                    <a href="{% url 'course_deallocate' pk=course.pk %}" class="delete" title="Deallocate">
                        <i class="fas fa-trash-alt"></i>
                    </a>
                    </div>
                </td>
                {% endif %}
            </tr>
            {% empty %}
            <tr>
              <td></td>
              <td></td>
              <td>
                <span class="text-danger">No Course Allocated.
                    {% if request.user.is_superuser %}
                    <a href="{% url 'course_allocation' %}">
                    <i class="primary" style="font-size: 22px;">
                    Allocate now
                    </i>
                    {% endif %}
                    </a>
                </span>
                </td>
              <td></td>
            </tr>

        </tbody>
        {% endfor %}
    </table>
</div>
{% endblock content %}
