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

{% load i18n %}
{% load publisher_extras %}

{% 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 "Organization" %}
                    </th>
                    <th role="button">
                        {% trans "Project Coordinator" %}
                    </th>
                    <th role="button">
                        {% trans "Runs" %}
                    </th>
                    <th role="button">
                        {% trans "Course Team" %}
                    </th>
                    <th role="button">
                        {{ site_name }}
                    </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>
                            {{ course.organization_name }}
                        </td>
                        <td>
                            {{ course.project_coordinator.full_name }}
                        </td>
                        <td>
                             {{ course.publisher_course_runs.count }}
                        </td>
                        <td>
                            {{ course.course_state.course_team_status.status_text }}<br>
                            {{ course.course_state.course_team_status.date|date:'m/d/y' }}
                        </td>
                        <td>
                            {{ course.course_state.internal_user_status.status_text }}<br>
                            {{ course.course_state.internal_user_status.date|date:'m/d/y' }}
                        </td>
                        <td>
                            {% if not publisher_hide_features_for_pilot and course|can_edit_course:request.user %}
                                <a href="{% url 'publisher:publisher_courses_edit' course.id %}" class="btn btn-brand btn-small btn-course-edit">
                                  {% trans "Edit" %}
                                </a>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}

{% block extra_js %}
    <script>
        $(document).ready(function() {
            $('#dataTableCourse').DataTable({
                "autoWidth": false,
                "oLanguage": { "sEmptyTable": gettext("No courses have been created.") }
            });
        });
    </script>
{% endblock %}
