{% extends 'publisher/base.html' %}
{% load i18n %}

{% block title %}
    {% trans "Courses" %}
{% endblock title %}

{% block page_content %}
    <h2 class="hd-2 course-count-heading">{{ object_list.count }} Courses</h2>
    <a href="{% url 'publisher:publisher_courses_new' %}" class="btn btn-brand btn-small btn-course-add">
        {% trans "Create New Course" %}
    </a>
    <div class="coursesTable">
        <table id="dataTableCourse" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th role="button">
                        {% trans "Course Name" %}
                    </th>
                    <th role="button">
                        {% trans "Institution" %}
                    </th>
                    <th role="button">
                        {% trans "Project Coordinator" %}
                    </th>
                    <th role="button">
                        {% trans "Runs" %}
                    </th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {% for course in object_list %}
                    <tr>
                        <td>
                          {% if publisher_hide_features_for_pilot %}
                            {{ course.title }}
                          {% else %}
                            <a href="{% url 'publisher:publisher_course_detail' course.id %}">
                                {{ course.title }}
                            </a>
                          {% endif %}
                        </td>
                        <td>
                            {% if course.organizations.first %}{{ course.organizations.first.name }}{% endif %}
                        </td>
                        <td>
                            {{ course.project_coordinator.full_name }}
                        </td>
                        <td>
                             {{ course.publisher_course_runs.count }}
                        </td>
                        {% if not publisher_hide_features_for_pilot %}
                          <td>
                            <a href="{% url 'publisher:publisher_courses_edit' course.id %}" class="btn btn-brand btn-small btn-course-edit">
                              {% trans "Edit" %}
                            </a>
                          </td>
                        {% endif %}
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}

{% block extra_js %}
    <script>
        $(document).ready(function() {
            $('#dataTableCourse').DataTable({
                "autoWidth": false,
                "oLanguage": { "sEmptyTable": gettext("Looks like you haven't created any course yet") }
            });
        });
    </script>
{% endblock %}
